Quick if/else question
Posted: Sun Jul 24, 2011 6:24 pm
Hi all,
I'm building a booking system (LAMP).
I have a row "places" (an INT) which has the number of available places on any given course.
The starting value is 10.
I can subtract from the available places each time a booking is made like this:
$result = mysql_query ("UPDATE live_1 SET places = places -1");
But if I run the script again and again it goes into minus figuers -1, -2, -3 etc.
As a Flasher I know how to limit this to zero in Actionscript with an if statement like this:
if (places == -1) {
places = 0
}
but I'm struggling to get the syntax right in php.
Any ideas ?
Best wishes
Monty
I'm building a booking system (LAMP).
I have a row "places" (an INT) which has the number of available places on any given course.
The starting value is 10.
I can subtract from the available places each time a booking is made like this:
$result = mysql_query ("UPDATE live_1 SET places = places -1");
But if I run the script again and again it goes into minus figuers -1, -2, -3 etc.
As a Flasher I know how to limit this to zero in Actionscript with an if statement like this:
if (places == -1) {
places = 0
}
but I'm struggling to get the syntax right in php.
Any ideas ?
Best wishes
Monty