Well, first, you should look into moving up to MySQLi (the ‘i’ is for improved) as the older MySQL has been
deprecated and will not work at some point in the future. There are only a few minor changes to your code
to use the newer improved version.
Now, near the end of your code, you have this:
if (isset($_post['Submit'])){
for ($i=0;$i<$count;$i++){
$sql1 = "update test_mysql set name='$name[$i]', job='$job[$i]', time1='$time1[$i]', time2='$time2[$i]' where id='$id[$i]'";
$result1 = mysql_query ($sql1);
}
}
if ($result1){
header('location:update_multiple.php');
}
If you look at just that outside of the rest of the code, you will see that you close the IF clause before you
check to see if there are results. The problem is that if a user does NOT press the SUBMIT button, the PHP
code still evaluates the results and since it does not exist until they press the button, it throw an error.
Just take out the extra closing brace right before the checking of results... Like this:
[php]
if (isset($_post['Submit'])){
for ($i=0;$i<$count;$i++){
$sql1 = "update test_mysql set name='$name[$i]', job='$job[$i]', time1='$time1[$i]', time2='$time2[$i]' where id='$id[$i]'";
$result1 = mysql_query ($sql1);
}
if ($result1){
header('location:update_multiple.php');
}[/php]
But, this brings up another big problem. You are looping thru a number of queries that do updates on a
table. Then, you just check the last query results. Not sure if that is a good thing to do. If the first of
five queries worked and the last one did not, you would not get a valid results. Most likely you should
update all of the data and then create a new query that counts the table's entries. Not sure of your
logic there.
Hope that helps… Good luck…