PHP update mysql table, subtract by 1 -


i trying ticketing system. when user has registered successfully, subtract available ticket seats 1.

$availseats = $_post['myavailseats']; //3  //once registration info entered, minus available seats  $sql = "update tblcourseinfo set         availseats = --$availseats         courseid = '$courseid'"; 

however when statement queried, availseats updated 0 instead of 2. data type int availseats. why happening?

edit:

thanks helped me. here solution has provided:

$availseats = $_post['myavailseats']; // 3  //once registration info entered, minus available seats  --$availseats; // decrease seat 1 first  $sql = "update tblcourseinfo set         availseats = --$availseats         courseid = '$courseid'"; 

if availseats had value, subtract directly mysql may work:

$sql = "update tblcourseinfo set availseats = availseats - 1 courseid = '$courseid'"; 

or subtract $availseats before query.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -