//edit.php  
<?php  
//connect to database  
mysql_connect('localhost', 'mysql_user', 'mysql_password');  
mysql_select_db('dbname');  
  
//pull info from $_POST and sanitize it  
$id = mysql_real_escape_string($_POST['id']);  
$title = mysql_real_escape_string($_POST['title']);  
$genre = mysql_real_escape_string($_POST['genre']);  
$description = mysql_real_escape_string($_POST['description']);  
  
//update in database  
$query = 'Update books SET title="'.$title.'", genre="'.$genre.'", description="'.$description.'" WHERE id="'.$id.'"';  
mysql_query($query);  
  
//generate json code  
echo json_encode(array(  
 'id'=>$id,  
 'title'=>$title,  
 'genre'=>$genre,  
 'description'=>$description  
));  
?> 