I am creating a website for book rental system. Here I do the work of librarian where inserting the book details are done. So here i want to update the availability of the book if the name of the book is already inserted. My query goes like this. And whenever I try to update the availability of the book the value again gets inserted.
$name=$_POST['bname'];
$avail=$_POST['avail'];
$q=mysql_query("select * from table where name='$name'");
if($name==$q){
$n=("update table where name='$name' set avail='$avail'+1")
}