I am trying to write code that can update record in a table. I have a FORM with two checkbox,s named "repaired" using the format of:
<input name="repaired[]" type="checkbox" id="repaired" value="1" />
When the FORM loads it can contain any number of records row by row and each row has a "HIDDEN" FORM field containing a unquieid for that record.
If the user selects any of the records by selecting it's corrosponding "CHECKBOX", and then submits the form I need to LOOP through each selected record and update a table.
My FORM code:
<form id="form1" name="form1" method="post" action="<?php echo $editFormAction;?>">
<?php
do {
echo $row_Faults['SeqID'];
echo $row_Faults['SeqHeader'];
echo $row_Faults['Room'];
<input name="repaired[]" type="checkbox" id="repaired" value="1" />
<input name="UniqueID" type="hidden" value="<?php echo $row_Faults['UniqueID'];?>" />
} while ($row_Faults = mysql_fetch_assoc($Faults));
?>
<input type="image" src="../images/actioned_button.png" name="button" id="button" value="1" />
<input name="MM_update" type="hidden" value="form1" />
<input name="submit" type="hidden" value="submit" />
</form>
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
if(!empty($_POST['UniqueID']) && $_POST['repaired'] == "1"){
foreach($_POST['repaired'] as $Selected){
//THIS IS WHERE I AM STUCK
UPDATE QUERY.......
}
}
}
This is where I am stuck, how can I loop through the $_POST data and update the records where the "UniqueID" matches the $_POST['UniqueID'] and if $_POST['repaired'] == 1.
Any help or a pointer to what I need to do would be great,
Many thanks in advance for your time.