I am doing a validation statement where i will get the number of ticket from my database and validate against the one entered by the user($_POST[ticket]) to see if there is enough ticket.But it doesnt seem to get the number of ticket from the database.Any help would be appreciated thanks~
$db = new Database('localhost','lucashii','112233','movies');
$sql = 'SELECT ticket_num FROM movie_ticket WHERE movieticket_id = "'.$_POST['id'].'"';
$result = $db->query($sql);
$row = $db->sql_fetchrow($result);
$ticketa = $row['ticket_num'];
if ($ticketa < 0) {
echo 'TResult1='.urlencode('Ticket Sold Out');
} else{
$POST['currentTicke'] = $POST['currentTicket'] - $POST['ticket'];
$db = new Database('localhost','lucashii','112233','movies');
$sql = 'UPDATE movie_ticket SET ticket_num = "'.$POST['currentTicke'].'" WHERE ticket_id = "'.$_POST['id'].'"';
$db->query($sql);
echo 'TResult1='.urlencode('Success');
}
?>