I did the mofications as per your suggestions:
Form 1:
<form action=form2.php?l=<?php echo $l; ?>&username=<?php echo $username; ?>&password=<?php echo $password; ?> method=post enctype="post">
<?
$sql2 = mysql_query("select * from catlisting") or die("Unable to process queries at this time: " . mysql_error());
while($row2 = mysql_fetch_array($sql2)) {
$cat = $row2["category"];
$result2 .= "<OPTION value=\"$cat\">$cat</option>";
}
echo "<table width=90% border=1><tr>";
$sql = mysql_query("select * from categories WHERE username = '$username'") or die("Unable to process queries at this time: " . mysql_error());
hile($row = mysql_fetch_array($sql)) {
$i = "1";
echo "<td><div align=center><select name=\"" . $row["id"] . "\" value=\"" . $row["category"] . "\">";
echo "<option value=\"" . $row["id"]. "\"> " . $row["category"] . "";
echo "$result2";
$i++ ;
}
}
echo "</select></div></td></tr><tr><td colspan=4 align=center valign=middle>";
echo "<input type=\"submit\" value=\"" . $lang[1017] . "\"></td></tr>";
echo "</table>";
?>
</form>
In form2
foreach($_POST as $key => $value) {
$query = mysql_query("UPDATE categories SET category='$value' WHERE id='$key'") or die(mysql_error());
}
This works well. HOwever, if I go back to previous page using the back button on browser, do not make any change to any of the fields and hit the submit button, all the input in the fields are replaced by the name of the field.
ie if I had: id, category
82 , Algebra
83, Chemistry
when i hit the submit button without changer the categories the result I get is
82,82
83,83
Is there a way to keep the old values in place?