** update in an array brick wall **
Posted: Fri Jan 23, 2004 12:41 pm
i'm full done with this site except for this one brick wall i've hit - i need to be able to update the one field "status" for each of the rows with the same "recID" field *separately*:
i was given this:
but it is only updating status field to random chioces of the four options, not the option selected...
someone please help? this has brought the finishing of the site to a standstill...
thanks very much,
glennn
Code: Select all
<?
$grab_usertitles = "SELECT * FROM titles WHERE recID = '$id'";
$result = @mysql_query($grab_usertitles);
sql_query("$result", "1", "$errorsї03]");
while ($row = mysql_fetch_array($result))
{
$tid = $rowї"id"];
$title = $rowї"title"];
$status = $rowї"status"];
echo "<tr><td width="150">$tid - $title </td><td width="400">
<select name=statusї". $i ."]"><option value="$status">$status</option>
<option value="Received">Received</option>
<option value="Under Review">Under Review</option>
<option value="Approved">Approved</option>
<option value="Declined">Declined</option>
</select></td></tr>";
}
?>Code: Select all
$status = $_POSTї'status']; // if your form's method is POST
$updates = array();
foreach($status as $key=>$value)
{
$updatesї] = "UPDATE titles SET status = '". $value ."' WHERE id = $key";
}
// Then finally loop through the $updates array to execute the updates:
for($i=0;$i<count($updates);++$i)
{
$success = mysql_query($updatesї$i]);
}someone please help? this has brought the finishing of the site to a standstill...
thanks very much,
glennn