Hi all,
This is stumping me.
I have a snippet of code that is supposed to show a customers ticket numbers (performed in a loop) then update the two fields in my database one time.
I get the correct display of the ticket numbers for my test data.
table 3 is handled correctly as well. The update to table 2 is messed up though. If I bought 2 tickets, it will be updated showing that I bought 4 tickets...every test I've run, it's been twice the amount it should be.
Please help if you can.
BTW, no error messages on my php pages.
Thanks so much
<?
for ($i = 0; $i <= $quantity; $i++) {
//for testing ticket number value
print ("you bought ticket number $starting_ticket<br>");
$enter_tickets_query = "INSERT INTO $table3(user_id, item_id, ticket_number) VALUES (\"$user_id\", \"$item_id\", $starting_ticket\")";
$result = mysql_db_query($dbase, $enter_tickets_query, $con);
$starting_ticket++;
}
$tickets_remaining = $tickets_remaining - $quantity;
$update_item_query = "UPDATE $table2 SET tickets_remaining=\"$tickets_remaining\", starting_ticket=\"$starting_ticket\" WHERE item_id = \"$item_id\"";
$result = mysql_db_query($dbase, $update_item_query, $con);
?>