Hi,
I have a question: I want to update more than 1 value in a table.
My table has the following structure:
Value
id (int)
price (int)
city (int, fkey to city table)
good(int, fkey to good table)
Ok i've made a php where you can change the prices of a good for 1 particulary city.
So it displays a couple of input=text fields for each good in 1 city.
No my problem is how to update the table?
I past some of the code i have:
<form action="updateValueTable.php" method="post">
<?
$result = mysql_query( "SELECT id, price FROM value WHERE city=$ud_city ORDER BY id" )
while ($teller<$num_rows)
{
print "
\t<tr>\n
<td class=\"Main\"><div align=\"left\">\n
$good
</td>\n
<td><div align=\"right\">\n
<input type=\"hidden\" name=\"ud_id\" value=\"$id\">\n
<input type=\"text\" name=\"ud_price\" value=\"$price\" size=\"7\" maxlength=\"7\" height=\"1\" class=\"infoTabel\">\n
</td>
</tr>\n";
$teller++;
}
?>
</form>
And in the updatevaluetable.php I have this:
<?
mysql_query("UPDATE value SET price = '" . $_POST['ud_price'] . "' WHERE id = '" . $_POST['ud_id'] . "'")
or die("Couldn't update: ".mysql_error());
print "<div align=\"center\">Table Updated</div>";
mysql_close($link);
?>
Displaying the data in the input=text fields works. Now i only need to know how to update these values.
Can someone help me or give a hint how to solve it otherwise?
Thanks