Copy link to clipboard
Copied
I am having a slight problem in trying to figure out a way to create a form and have it update multiple rows in my database that are under the same table. When I think this through...I get that sensation you get when you contemplate a never-ending Universe or an always-existing-God.
Quickly, the issue is in the fact that when I fill out the form I built - it only updates every other row in the database. In much more depth, here is what I have done:
1. I created a form on a blank page.
2. I hit enter three times for vertical space within the form.
3. I inserted nine text fields: (Each field corresponding to fields in the database. Being Employee ID, Employee Name, Days of the week for scheduling.)
4. I created a Recordset that consisted of all the appropiate information from the database.
5. I clicked on Bindings and then dragged each item (id, employee, etc) to its corresponding text field in the form. This way, it would automatically populate it.
6. I put a submit button.
7. I went to Server Behaviors and chose Update Record.
Now, at this point in time I knew two things:
1. It would pull the first employee in the database and display the information inside the text fields.
2. It would work.
And it did work. It showed the correct information and then updated the database correctly when I hit submit.
8. So then I selected one of the fields and clicked the < tr > tag at the bottom of the window to select the whole row.
9. I went to Server Behaviors and chose Repeat Region, chose ALL and hit okay.
10. I prayed, danced around my cat and ate some carrots in preperation of seeing if it works or not.
It did not.
Not entirely.
So now, I can have three employees in the database, or fifty. It doesn't matter. If I go through and fill out the schedule and hit submit, it will only update every other employee. See screenshot below:
I have no idea why. Even shaving my cat didn't help any. Any ideas? Suggestions? Solutions?
Below is the code from my page. I have no idea why the head stuff is in the middle of the page.
----------------------------------------------------------------------------------------------------------------------------------------------------------
<?php require_once('Connections/check_emp.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE employees SET employee_name=%s, Monday=%s, Tuesday=%s, Wednesday=%s, Thursday=%s, Friday=%s, Saturday=%s, Sunday=%s WHERE id=%s", GetSQLValueString($_POST['employee_name'], "text"), GetSQLValueString($_POST['Monday'], "text"), GetSQLValueString($_POST['Tuesday'], "text"), GetSQLValueString($_POST['Wednesday'], "text"), GetSQLValueString($_POST['Thursday'], "text"), GetSQLValueString($_POST['Friday'], "text"), GetSQLValueString($_POST['Saturday'], "text"), GetSQLValueString($_POST['Sunday'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_check_emp, $check_emp); $Result1 = mysql_query($updateSQL, $check_emp) or die(mysql_error()); } mysql_select_db($database_check_emp, $check_emp); $query_getSchedule = "SELECT id, employee_name, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday FROM employees ORDER BY id ASC"; $getSchedule = mysql_query($query_getSchedule, $check_emp) or die(mysql_error()); $row_getSchedule = mysql_fetch_assoc($getSchedule); $totalRows_getSchedule = mysql_num_rows($getSchedule); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <table width="900"> <tr> <td>id</td> <td>emp</td> <td>mon</td> <td>tue</td> <td>wed</td> <td>thur</td> <td>fri</td> <td>sat</td> <td>sun</td> </tr> <?php do { ?> <tr> <td><input name="id" type="text" disabled="disabled" id="id" value="<?php echo $row_getSchedule['id']; ?>" readonly="readonly" /></td> <td><input name="employee_name" type="text" disabled="disabled" id="employee_name" value="<?php echo $row_getSchedule['employee_name']; ?>" readonly="readonly" /></td> <td><input name="Monday" type="text" id="Monday" value="<?php echo $row_getSchedule['Monday']; ?>" /></td> <td><input name="Tuesday" type="text" id="Tuesday" value="<?php echo $row_getSchedule['Tuesday']; ?>" /></td> <td><input name="Wednesday" type="text" id="Wednesday" value="<?php echo $row_getSchedule['Wednesday']; ?>" /></td> <td><input name="Thursday" type="text" id="Thursday" value="<?php echo $row_getSchedule['Thursday']; ?>" /></td> <td><input name="Friday" type="text" id="Friday" value="<?php echo $row_getSchedule['Friday']; ?>" /></td> <td><input name="Saturday" type="text" id="Saturday" value="<?php echo $row_getSchedule['Saturday']; ?>" /></td> <td><input name="Sunday" type="text" id="Sunday" value="<?php echo $row_getSchedule['Sunday']; ?>" /></td> </tr> <?php } while ($row_getSchedule = mysql_fetch_assoc($getSchedule)); ?> </table> <p> </p> <p> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <p> </p> <input type="hidden" name="MM_update" value="form1" /> </form> <p><a href="admin/add_employee.php">Add Employee</a></p> </body> </html> <?php mysql_free_result($getSchedule); ?>
This is what the amended code should look like:
...<?php require_once('Connections/check_emp.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
Copy link to clipboard
Copied
Drymetal wrote:
I have no idea why. Even shaving my cat didn't help any. Any ideas? Suggestions? Solutions?
Cats don't like being shaved and tend to take their revenge by embedding sharp claws in sensitive parts of your body. A far better solution is to learn the technology you're trying to use.
The server behaviors in Dreamweaver are intended for quick prototyping and/or as a learning tool. They are not recommended for use in a production situation.
There are several problems with your page.
First of all, you are using IDs in a loop (repeat region). This results in the same ID being inserted in the page multiple times. An ID should be used only once in a page.
Secondly, the Update Record server behavior is capable of updating only one record. It cannot be used to update multiple records without being customized.
Thirdly, to submit multiple values from form fields that share the same name, you need to submit them as an array. In PHP, you do so by adding an empty pair of square brackets after the field name like this:
name="employee_name[]"
Finally, the ID field in your form is disabled. That means the value won't be submitted with the form. Instead of disabled, you should be using readonly.
I need to disappear for a short while, but I'll post the correct code for you a bit later.
Copy link to clipboard
Copied
This is what the amended code should look like:
<?php require_once('Connections/check_emp.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
// find the number of employees
$count = count($_POST['id']);
// if a positive number is returned, proceed with update
if ($count) {
// select the database
mysql_select_db($database_check_emp, $check_emp);
// loop through the subarrays to insert the values
for ($i = 0; $i < $count; $i++) {
// use $i to access the correct element in each subarray
$updateSQL = sprintf("UPDATE employees SET employee_name=%s, Monday=%s, Tuesday=%s, Wednesday=%s, Thursday=%s, Friday=%s, Saturday=%s, Sunday=%s WHERE id=%s",
GetSQLValueString($_POST['employee_name'][$i], "text"),
GetSQLValueString($_POST['Monday'][$i], "text"),
GetSQLValueString($_POST['Tuesday'][$i], "text"),
GetSQLValueString($_POST['Wednesday'][$i], "text"),
GetSQLValueString($_POST['Thursday'][$i], "text"),
GetSQLValueString($_POST['Friday'][$i], "text"),
GetSQLValueString($_POST['Saturday'][$i], "text"),
GetSQLValueString($_POST['Sunday'][$i], "text"),
GetSQLValueString($_POST['id'][$i], "int"));
$Result1 = mysql_query($updateSQL, $check_emp) or die(mysql_error());
}
}
}
mysql_select_db($database_check_emp, $check_emp);
$query_getSchedule = "SELECT id, employee_name, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday FROM employees ORDER BY id ASC";
$getSchedule = mysql_query($query_getSchedule, $check_emp) or die(mysql_error());
$row_getSchedule = mysql_fetch_assoc($getSchedule);
$totalRows_getSchedule = mysql_num_rows($getSchedule);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="900">
<tr>
<td>id</td>
<td>emp</td>
<td>mon</td>
<td>tue</td>
<td>wed</td>
<td>thur</td>
<td>fri</td>
<td>sat</td>
<td>sun</td>
</tr>
<?php do { ?>
<tr>
<td><input name="id[]" type="text" value="<?php echo $row_getSchedule['id']; ?>" readonly="readonly" /></td>
<td><input name="employee_name[]" type="text" value="<?php echo $row_getSchedule['employee_name']; ?>" readonly="readonly" /></td>
<td><input name="Monday[]" type="text" value="<?php echo $row_getSchedule['Monday']; ?>" /></td>
<td><input name="Tuesday[]" type="text" value="<?php echo $row_getSchedule['Tuesday']; ?>" /></td>
<td><input name="Wednesday[]" type="text" value="<?php echo $row_getSchedule['Wednesday']; ?>" /></td>
<td><input name="Thursday[]" type="text" value="<?php echo $row_getSchedule['Thursday']; ?>" /></td>
<td><input name="Friday[]" type="text" value="<?php echo $row_getSchedule['Friday']; ?>" /></td>
<td><input name="Saturday[]" type="text" value="<?php echo $row_getSchedule['Saturday']; ?>" /></td>
<td><input name="Sunday[]" type="text" value="<?php echo $row_getSchedule['Sunday']; ?>" /></td>
</tr>
<?php } while ($row_getSchedule = mysql_fetch_assoc($getSchedule)); ?>
</table>
<p> </p>
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
<p> </p>
<input type="hidden" name="MM_update" value="form1" />
</form>
<p><a href="admin/add_employee.php">Add Employee</a></p>
</body>
</html>
<?php
mysql_free_result($getSchedule);
?>
Making these changes will result in Dreamweaver no longer recognizing the Update Record server behavior. However, if you want to use server behaviors, you frequently need to customize them to achieve anything beyond the simplest of tasks. It's also unwise to use server-side code without understanding what it does. Time to start learning, rather than relying on incantations and abusing your cat.
Copy link to clipboard
Copied
The code you provided did in fact work. However, do to your suggestion and quite a bit of feedback from my cat - I've spent the entire day learning about php. Below is some things I learned. I figure learning it and then trying to understand why your code worked is essential to me accomplishing anything moving forward.
Ok, so a Variable is basically a street name. For instance, whenever we say "neurotic", we all know we are really talking about Anne Coulter. If the street name explanation doesn't work, then we'll go with "variables are to store values". So, if I write code that says:
<?php
$happy_variable = "chicken";
echo $happy_variable;
?>
It will make the page say "chicken". On the other hand, let's say I want to prove that chickens can be turned into kangeroos, I could type:
<?php
$happy_variable = "chicken";
echo $happy_variable;
echo "<br />";
$happy_variable = "ostrich";
echo $happy_variable;
?>
It will make the page show:
chicken
ostrich
Sadly, kangeroos are out of the question.
I think I can even put variables in variables. : )
<?php
$sad_variable = "chicken";
$happy_variable = "sand {$sad_variable} wich";
echo $happy_variable;
?>
Now, I can assign a string to a variable, two strings to a variable or even add a single string to a variable and tell it to add something extra. For instance:
<?php
$sad_variable = "chicken";
$confused_variable = "ostrich";
$happy_variable = "sand {$sad_variable} wich";
$question = "Why did the {$sad_variable}" . " " . "become an {$confused_variable}?";
echo $question . "<br />Because otherwise, it'd be a {$happy_variable}";
?>
That will say:
Why did the chicken become an ostrich?
Because otherwise, it'd be a sand chicken wich
Now, string functions. Oh..the poor pea in my head.
<?php
$NoGood = "Joined congress";
$Duh = "What";
$FatCat = "My precious fat cat<br />";
$BigMac = "everyone who has been to McDonalds.";
$NotCertain = "Nevermind, ya know ";
$Like_A_Third_Grader = "?";
$TellYou = "tell you";
$Jerry = " Jerry Springer show";
$NeverKnow = "on the";
$WhatDoYouThink = "must have";
$MyBrain = " ";
$MightBeUseful = "!";
$GettinThere = $NeverKnow;
$GettinThere .= $Jerry . $MyBrain . $WhatDoYouThink;
?>
<?php echo $FatCat; ?>
<?php echo strtolower ($Duh . $Like_A_Third_Grader); ?><br />
<?php echo ucwords($FatCat); ?>
<?php echo strtoupper($Duh . $Like_A_Third_Grader); ?><br />
<?php echo ucwords($FatCat); ?>
<?php echo strtoupper($Duh . $MightBeUseful . $Like_A_Third_Grader); ?><br />
<?php echo $NotCertain; ?>
<?php echo str_replace("to McDonalds.", " ", $BigMac); ?>
<?php echo $MyBrain . $GettinThere . " " . strtolower($NoGood) . str_repeat($MightBeUseful, 10); ?><br />
<?php echo "What about the cat?" ?>
And then the wonderful world of numbers. Let's see if I get this:
<?php
$number = 5;
$number2 = 10;
$number3 = 1;
echo "For a good time, please call ";
?>
<?php echo (($number * $number2) * $number2 + ($number2 * $number + $number)); ?>
<?php echo "-"; ?>
<?php echo ($number * $number2 * $number2 + $number2 + $number2 + $number2 + $number2 + $number2 + $number); ?>
<?php echo "-"; ?>
<?php echo "$number"; echo "$number"; ?>
<?php echo ($number * $number2) + $number; ?>
Arrays. Oh lord. If anything can make this poor pea in my head hurt...arrays is it. I'll see if I can do a simpler one from what I learned today:
<?php
$thirsty = " and drink "
?>
<?php $happy_array = array("chicken", "cat", "elephant", array("hippity", "hoppity", array("kung fu",4, array("dancing ninjas", "september", array("slimfast", "Taco Bell"))))); ?>
<?php echo $happy_array[0] . " likes to go" . " " . $happy_array[3][0] . " " . $happy_array[3][1] . $thirsty . $happy_array[3][2][2][2][0]; ?>
Ok, good. That one worked. I also learned about associations. So, let's see if I can do that. : )
<?php
$JerryLewis = array("first_name" => "Bob", "last_name" => "Wattenibble");
$JerryLewis["first_name"] = "Wooly";
echo $JerryLewis["first_name"] . " " . $JerryLewis["last_name"] . " " . "has a pet rabbit named Harry.";
?>
Ok great. That worked for me too. But then I got curious. How in the world can I keep track of an array if it gets complicated? Then I learned about Print Readable. SO:
<?php
$happy_array = array("chicken", "cat", "elephant", array("hippity", "hoppity", array("kung fu",4, array("dancing ninjas", "september", array("slimfast", "Taco Bell"))))); ?>
<pre><?php print_r($happy_array); ?></pre>
It works! I get a cool little graphic showing me what everything is. That got me so excited I had to run around the house screaming. Now, one thing I'm not entirely sure about is when I use this code:
<?php
$happy_array = array("chicken", "cat", "elephant", array("hippity", "hoppity", array("kung fu",4, array("dancing ninjas", "september", array("slimfast", "Taco Bell"))))); ?>
<?php sort($happy_array); ?><br />
<?php echo $stuff = implode(", ", $happy_array); ?>
Why does it not provide everythin in my array? And how do I make it not list the word "array" in the string? Strange stuff. My poor, poor pea...
So then, I learned about Booleans and Null. I actually got excited about this for some strange reason. So here is what I learned:
<?php
$cousin = "Eddie";
$christmas = "lights";
$KateMossWeighs = 0;
$In_Text = "0";
?>
$Cousin is set? <?php echo isset($cousin); ?><br />
$christmas is set? <?php echo isset($christmas); ?><br />
$In_Text is set? <?php echo isset($In_Text); ?><br />
$Griswald is set? <?php echo isset($Griswald); ?><br />
<?php unset($christmas); ?>
$Cousin is set? <?php echo isset($cousin); ?><br />
$christmas is set? <?php echo isset($christmas); ?><br />
$In_Text is set? <?php echo isset($In_Text); ?><br />
$Griswald is set? <?php echo isset($Griswald); ?><br />
<br />
Is $cousin empty? <?php echo empty($cousin); ?><br />
Is $KateMossWeighs empty? <?php echo empty($KateMossWeighs); ?><br />
Is $In_Text empty? <?php echo empty($In_Text); ?><br />
I found out that I need to be careful if I use empty. Pretty cool stuff though. I also learned about floating pointers and constants. Tomorrow I am learning a whole new world of php and so on. Thanks for your help.
Copy link to clipboard
Copied
Drymetal wrote:
The code you provided did in fact work.
That's good to know.
Now, one thing I'm not entirely sure about is when I use this code: <?php $happy_array = array("chicken", "cat", "elephant", array("hippity", "hoppity", array("kung fu",4, array("dancing ninjas", "september", array("slimfast", "Taco Bell"))))); ?> <?php sort($happy_array); ?><br /> <?php echo $stuff = implode(", ", $happy_array); ?>
Why does it not provide everythin in my array? And how do I make it not list the word "array" in the string?
It simply displays Array because you're trying to use implode() with a multidimensional array. It works only with simple arrays. You would need to unravel the rat's nest of arrays that you have created before passing the result to implode(). It's an unrealistic example, so I'm not even going to attempt to try to provide a solution.
Copy link to clipboard
Copied
Unrealistic or not, at least I did take your advice and spent an entire day and night reading about php, which should -at the very least- show that I do have an interest in learning. Is the sharing of knowledge only quantifiable so long as it is serious and confounded to the known barriers of reality?
"Children want to learn to the degree that they are unable to distinguish learning from fun. They keep this attitude until we adults convince them that learning is not fun."
-- Glenn Doman, founder of The Institutes for the Achievement of Human Potential
Either way, I do appreciate your help. You providing code that did work inspired me. To just look at code and find errors and know immediately what is wrong is pretty awesome and it makes the whole coding thing seem less intimidating. Thank you.
Copy link to clipboard
Copied
Drymetal wrote:
Unrealistic or not, at least I did take your advice and spent an entire day and night reading about php, which should -at the very least- show that I do have an interest in learning. Is the sharing of knowledge only quantifiable so long as it is serious and confounded to the known barriers of reality?
There's absolutely nothing wrong with experimenting in the way that you did. In fact, it's very gratifying that you took to heart the message about the need to understand the code you're working with.
However, programmatically unravelling the complex array that you created would take some time and thought. If it were a real example, the advice from most experienced programmers would be to restructure your data rather than attempt to handle such complexity.
Copy link to clipboard
Copied
Ok fair enough. I'll buy you some soda if you're ever in Columbus, OH. ![]()
I have a quick question, then I'll leave this post alone since you answered it and I don't want Adobe or anyone getting mad at me for carrying on.
I've spent an exceptional amount of time over the past three days learning about PHP. Here is what I have learned so far:
Variables
Strings
String Functions
Integers & Floating Points
Arrays
Array Functions
Booleans & NULL
Type Switching & Casting
Constants
If, Else & Elseif statements
Logical operators
Switch Statements
While, For & Foreach loops
- Continue, Break & Array Pointers
Functions
Returning Values form Functions
Setting Global variables & setting default values
I also did a tutorial series you did on Dreamweaver
So now, I feel I can sort of look at PHP and at least have an idea on what I am looking at. I want to start writing my own little programs to strengthen and solidfy what I've learned. However, I still feel lost.
So, you seem to be the God of PHP and Dreamweaver. Or at least if nothing else - the man. So do you mind me asking you for your advice in how I should approach learning more? How I can become profiecient in PHP? etc? I've taken large steps to learn but now I've hit a brick wall and don't know exactly what routes will be most beneficial.
Thanks!
Copy link to clipboard
Copied
Drymetal wrote:
Ok fair enough. I'll buy you some soda if you're ever in Columbus, OH.
There's a little pond in the way of me popping over to Ohio. But I appreciate the thought.
I have a quick question, then I'll leave this post alone since you answered it and I don't want Adobe or anyone getting mad at me for carrying on.
This is a user-to-user forum, which is very lightly regulated. Adobe's quite happy as long you don't break the community guidelines by being offensive or posting spam. However, it's always a good idea to start a new thread for each topic. This discussion is still relevant to your original question, so it's no problem.
So do you mind me asking you for your advice in how I should approach learning more? How I can become profiecient in PHP? etc? I've taken large steps to learn but now I've hit a brick wall and don't know exactly what routes will be most beneficial.
You've done a huge amount. I'm very impressed. A lot of people who come to these forums expect to be spoonfed or insist that they don't have time to learn.
I can understand your feeling about hitting a brick wall. I went through the same feeling many years ago when I first started learning PHP. Understanding the syntax of a language is important, but things won't fall into place until you start using PHP in a practical way. Take a look at the changes I made to your code. Adding the square brackets after the form names told PHP to treat fields with the same name as subarrays of the $_POST array, which contains all the data submitted by a form that uses the POST method. To update each record, I passed $_POST['id'] as an argument to count() to find out how many records needed to be updated, and then used a for loop to iterate through each one in turn. Using $i as the counter, each record was updated using $_POST['id'][$i] and so on.
The best way to learn is to set yourself a task and try to write the code yourself. Start with modest tasks to avoid getting tied into knots. If you run into difficulties, post a question here or in a specialist PHP forum. Although this is officially a Dreamweaver forum, general PHP questions often get asked. If I'm around, I'll try to help. There are a couple of others who also have good PHP skills.Unfortunately, I've been away from this forum for a few months because of pressure of work, and the level of participation seems to have dropped off.
If you're looking for inspiration as to how you might use PHP, you might want to consider getting one of my books. I updated my most popular book, PHP Solutions, late last year. So, the second edition is bang up to date. As the title suggests, it contains a series of practical projects, such as sending emails, uploading images, reading and writing files, and working with a database. It's written in tutorial style in relatively short sections, and tells you not only what code to use but also explains why. You can find out more about the book on my website at http://foundationphp.com/phpsolutions/.
Copy link to clipboard
Copied
Sorry it has taken so long to respond. I've been buried in the world of php. To the point even that I am dreaming about it.
On a good note however, I can at least just assign sheep to a loop and have them repeat nonstop in my head all night.
I purchased your book and have been processing it. I haven't gotten there yet - but I am glad to see you cover relational databases. For whatever reason, I'm having a hard time getting that. I'm also thankful for the way you went about writing this book as everything I am learning involves hands on work which is about the best way I can learn.
I also joined Lynda.com because they have some videos on php.
I've gone over your code and feel like I understand it, but one thing I noticed is that your version seems much more elegant. I know that is probably obvious given that yours works - but I think an important lesson for me is that I need to remind myself to keep things simple.
So, here is what I've decided. I've taken my original project I was working on and redesigned the idea so that I end up doing a lot more in php. I can't complete it now because I don't think I know enough, but at least I have a goal somewhere in the future. I have a question in regards to this though, but first I'll tell you my goal:
The Schedule thing will have this capability:
Admin will be able to add, modify or delete:
• Departments. (Department determines which schedule a name appears ((i.e., Management, FOH, BOH, etc))
• Employees.
- Name
- Security Level (user, manager, admin, etc.)
- Department - an employee can belong to different departments
- Phone
Schedules.
- Schedule Title (i.e., Management, FOH, BOH, etc)
- Select Start Day (Maybe their schedule starts on Thursday?)
- Select number of shifts to display (i.e., 1, 2 or 3)
- Option to begin with blank fields or "last saved" schedule.
Schedule will automatically populate with the names in the appropriate departments. If a person is already scheduled during a shift on another department's schedule, this will appear in the schedule being worked on.
Once a Schedule has been posted as final:
Ok, believe it or not, this whole thing came about from a younger brother and sister who live next door to me. They always pretend they have a restaurant of sorts and I thought it would be cool to build them a little scheduling application so they could start learning various computer/management skills. Even if it is all play. So there is no deadline or date I need to complete this. And even if it never gets used, at least I'm being creative and learning something.
Now, I know from the list I have a lot of work cutout for me. But here are some issues I am having now in drawing plans for it: (I know I still have more to learn before this becomes possible.)
My issue is with the database. I know I need to keep things simple and broken down into their most simplest of parts.
So I presume I need three tabls:
Employees
Schedule
Departments
I mean given this type of information - how would you approach the layout of the database? Would schedule days be under employees? A forth table? How would the relational parts look? I'm having a really hard time wrapping my head around how to layout the database. And your input would be greatly appreciated.
My thought on this project is that I can do various parts as I learn about them. You know, it has easy parts and harder parts. Anyways, thanks. Also, will I want to buy PHP Object Oriented Solutions? And what about Adobe Dreamweaver CS5 with PHP: Training from the Source?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more