Hello-
I have a form which pulls a list of names by whether they are active or not. Each names row has a unique ID. The form then has two checkboxes which can be used to de-activate the name and/or also to change whether the name is displayed. The code should loop thru and update the table where the inactive and/or display columns are updated in relation to the ID if the checkboxes are checked.
But my code does not work. The rows are not updated.
Below is my (abbreviated) form code and my update loop. Any help would be greatly appreciated. Thanks.
<form>
<table>
$query = mysql_query("select * from names where inactive='0' ");
$result = $query;
while ($row = mysql_fetch_array($result)) {
echo("<td width=10% bgcolor=#ffffff><font color=white size=-1><input type=checkbox name='ID[]' value='" . $row["ID"] . "'><br>
<font face=Arial, Helvetica color=blue size=-1>Make Inactive</font></a></font></td>");
echo("<td width=10% bgcolor=#ffffff><font color=white size=-1><input type=checkbox name='displayed[]' value='displayed[" . $row["ID"] . "]'><br>
<font face=Arial, Helvetica color=blue size=-1>Do Not Display</font></a></font></td></tr>");
}
<input type=submit name=update value=update>
</table>
</form>
//the update code
$ID=$_POST['ID'];
foreach( $ID as $k)
{mysql_query("update names set inactive='1' where ID='$k'");}
$displayed=$_POST['displayed'];
foreach( $displayed as $m)
{mysql_query("update names set display='0' where where ID='$m'");}