When I press the save button it wont update the row if i make some changes. whats wrong with my code can you please help mee.
What is lacking or what do i need to put . Thanks for who will answer I will really appreciate it.
include("connect.php");
$code =$_GET['Code'];
$result = mysql_query("SELECT * FROM books WHERE Code = '$code'");
$row = mysql_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}
$code =$row['Code'];
$Title=$row['Title'] ;
$Price= $row['Price'] ;
$Stock=$row['Stock'] ;
if(isset($_GET['editsave']))
{
$title_save = $_GET['title'];
$price_save = $_GET['price'];
$stock_save =$_GET['stock'];
mysql_query("UPDATE books SET Title ='$title_save', Price ='$price_save',
Stock='$stock_save' WHERE Code= '$code'")
or die(mysql_error());
echo "Saved!";
header("Location: home_admin.php");
}
?>
<body>
<form method="get">
<table>
<tr>
<td>Title:</td>
<td><input type="text" name="title" value="<?php echo $Title ?>"/></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="price" value="<?php echo $Price ?>"/></td>
</tr>
<tr>
<td>Stock</td>
<td><input type="text" name="stock" value="<?php echo $Stock ?>"/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="editsave" value="save" /></td>
</tr>
</table>
</body>
</html>