My table populates rows with checkboxes. If the checkboxes are 'checked' and the Edit button is hit, the edit.php loads with all the rows that were checked.
Edit.php then allows me to edit certain text fields. However, if multiple rows were edited and the 'Update' button was hit, only the last row will update.
Here is edit.php ====
<?php
$con = mysql_connect("host", "user", "pass");
if (!$con)
{
die('Could not connect: ' .mysql_error());
}
mysql_select_db("dbname", $con);
echo "<body bgcolor='#E1E1E1'><font face='arial'>";
echo "<style type='text/css'>
body { background: #E1E1E1 url('bg.png');
background-attachment: fixed;
background-repeat: no-repeat;
background-position: center;
}
</style>";
if ($_POST['edit'])
{
foreach($_POST['edit'] as $key => $RequestNum)
{
// Get data from user with the specified id
$result = mysql_query("SELECT * FROM request WHERE RequestNum='".(int)$RequestNum."'") or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<form method='post' action=''>
<table width='450'>
<tr>
<td>Request Number:</td>
<td><input type='text' name='requestnum' id='requestnum' value='$row[RequestNum]' size='10' readonly /></td>
</tr>
<tr>
<td>Part Number:</td>
<td><input type='text' name='partnumber' id='partnumber' value='$row[PartNumber]' readonly /></td>
</tr>
<tr>
<td>Customer:</td>
<td><input type='text' name='customer' id='customer' value='$row[Customer]' readonly /></td>
</tr>
<tr>
<td>Quantity:</td>
<td><input type='text' name='quantity' id='quantity' value='$row[Quantity]' readonly /></td>
</tr>
<tr>
<td>Date Required:</td>
<td><input type='text' name='daterequired' id='daterequired' value='$row[DateRequired]' readonly /></td>
</tr>
<tr>
<td><b>Confirmed Date:</b></td>
<td><input type='text' name='confirmed' id='confirmed' value='$row[Confirmed]' /></td>
</tr>
<tr>
<td><b>Delivery Method:</b></td>
<td><input type='text' name='delivery' id='delivery' value='$row[Delivery]' /></td>
</tr>
<tr>
<td colspan='2'></td>
</tr>
</table>";
}
echo "<br /><input type='submit' name='Update' value='Update' /> </form>";
}
if ($_POST['Update']) {
$update="UPDATE request SET Confirmed='$_POST[confirmed]', Delivery='$_POST[delivery]' WHERE RequestNum='$_POST[requestnum]'";
mysql_query($update) or die ('Error Updating Data! <br />' .mysql_error());
echo "<center>Update successful</center>";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1; URL=result.php'>";
}
if (!$_POST['edit'])
{
//echo "<center>Please select at least one row to edit";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1; URL=result.php'>";
}
?>
Any ideas? I've wrapped my brain around this far too long with little progress.