mysql table edit form not working
Posted: Sat Feb 26, 2011 9:51 am
hi all, I'm trying to edit mysql table data from the browser using these:
edit_form.php:
edit_data.php:
edit.php:
this is the table:
CREATE TABLE IF NOT EXISTS `prices` (
`id_number` int(3) NOT NULL,
`product` varchar(30) DEFAULT NULL,
`price` int(6) DEFAULT NULL,
PRIMARY KEY (`id_number`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
everything is displayed correctly but when i try to insert new data it's not changing anything...
edit_form.php:
Code: Select all
<?
include "db.inc.php";//database connection
$order = "SELECT * FROM prices where id_number='$id'";
$result = mysql_query($order);
$row = mysql_fetch_array($result);
?>
<form method="post" action="edit_data.php">
<input type="hidden" name="id" value="<? echo "$row[id_number]"?>">
<tr>
<td>Product</td>
<td>
<input type="text" name="product"
size="20" value="<? echo "$row[product]"?>">
</td>
</tr>
<tr>
<td>Price</td>
<td>
<input type="text" name="price" size="40"
value="<? echo "$row[price]"?>">
</td>
</tr>
<tr>
<td align="right">
<input type="submit"
name="submit value" value="Edit">
</td>
</tr>
</form>Code: Select all
include "db.inc.php";
$order = "UPDATE prices SET product='$_POST[product]', price='$_POST[price]' WHERE id_number='$id'";
mysql_query($order);
header("location:edit.php");Code: Select all
include"db.inc.php";//database connection
$order = "SELECT * FROM prices";
$result = mysql_query($order);
while ($row=mysql_fetch_array($result)){
echo ("<tr><td>$row[id_number]</td>");
echo ("<td>$row[product]</td>");
echo ("<td>$row[price]</td>");
echo ("<td><a href=\"edit_form.php?id=$row[id_number]\">Edit</a></td></tr>");
}CREATE TABLE IF NOT EXISTS `prices` (
`id_number` int(3) NOT NULL,
`product` varchar(30) DEFAULT NULL,
`price` int(6) DEFAULT NULL,
PRIMARY KEY (`id_number`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
everything is displayed correctly but when i try to insert new data it's not changing anything...