Forum Moderators: coopster
I'm retrieving info from a a database, then the user has to select a number of unpredetermined records. When he does this, a flag for the selected record is set. But I experience problems when it comes to looping through the checkboxes to set the flags for the selected records.
Could someone please come to my rescue.
Thanks in advance.
1 - create an ARRAY OF CHECKBOXES and their values should be a unique value from the table which is unique for each record e.g primary key
2 - on the action page retrieve the Array of CheckBoxes in a foreach loop and perform queries
a dirty example could be
echo "<input type=checkbox name=cbox[] value=".$row['item_id'].">";
echo "<input type=checkbox name=cbox[] value=".$row['item_id'].">";
echo "<input type=checkbox name=cbox[] value=".$row['item_id'].">";
echo "<input type=checkbox name=cbox[] value=".$row['item_id'].">";
on the action page
if(sizeof($_POST['cbox'])) {
//means if at least one check box is selected
foreach($_POST['cbox'] AS $id) {
mysql_query("UPDATE tablename SET ... WHERE item_id=$id");
} //end foreach
} //end IF