Hi, I want to update multiple rows in my database.
Problem with this code is that it is only updating the last field.
I know it has something to do with unique names for the inpunt type= hidden and text fields.
So I supose i have to submit an array.
Plz tell me how to solve this problem
<form action="updateValueTable.php" method="post">
<table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#666666" class="Main">
<?
while ($tellerValue<$num_rowsValue)
{
$good=mysql_result($resultGood,$tellerValue,"name");
$id=mysql_result($resultValue,$tellerValue,"id");
$price=mysql_result($resultValue,$tellerValue,"price");
?>
<tr>
<td class="Main"><div align="left"><? print "$good" ?></td>
<td><div align="right">
<input type="hidden" name="ud_id" value="<? print "$id" ?>">
<input type="text" name="ud_price" value="<? print "$price" ?>" size="7" maxlength="7" height="1" class="infoTabel">
</td>
</tr>
<?
$tellerValue++;
} ?>
<tr>
<td align="left" class="Main"><? print "$cityName" ?></td>
<td div align="center"><input type="Submit" value="Upd"></td>
</tr>
</table></form>
And in the updateValueTable.php:
mysql_query("UPDATE value SET price = '" . $_POST['ud_price'] . "' WHERE id = '" . $_POST['ud_id'] . "'") or die("Couldn't update: ".mysql_error());
Thanks