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>&nbsp;</td>
    <td><input type="submit" name="editsave" value="save" /></td>
</tr>

</table>

</body>
</html>

I suggest you echo the query to see whether it is what you are expecting. Modifiy the part where you construct the query like this:

// put the query in a variable
$q = "UPDATE books SET Title ='$title_save', Price ='$price_save', Stock='$stock_save' WHERE Code= '$code'";

// submit query using the variable
mysql_query($q) or die(mysql_error(); 

// add this to display the query
die($q);

Now you will be able to see if the query gets constructed OK and you can copy it to phpmyadmin or mysql client and test it.

Two other notes:

  1. your form has no </form> tag. It should be after </table> tag.
  2. your form is missing an action attribute (I think it is required)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.