Unanswered: Querying for multiple SUM() values from a given table field.....
.....I need help on how to code a query statement and/or statements that would allow me to query a mysql table based on a set field (tix) and get the sum of that field for every instance of another field, $tourdate.
I would like to write the SUM(tix) as num_tix, then setup another variable called $availtix that would be:
$availtix = 25 - $num_tix;
The problem I have is figuring out how to do that when the $tourdate will vary depending on what's been inserted into the table.....
I tried that but couldn't seem to get it to work right....I suspect it's because I really don't have a loop that reads through the table records and pulls the recordset data out except the one initial result.....(if that's correct at all).
Again, I've read quite a bit on mysql and php, but I am still very new to this.
Anyway, what I am really needing to do at this point:
1. Query the mysql table (call it haunted) for SUM(tix) and tourdate;
2. Read through each record for the SUM(tix) and then take that returned value and subtract it from 25 to verify the number of actual tix available (I was thinking something like SELECT SUM(tix) as num_tix, tourdate from haunted GROUP BY tourdate ORDER by tourdate); then do $availtix = 25 - num_tix;
3. After I verify $availtix, then I need to be able to check that it's != 0, and if so, output SOLD OUT.
4. Otherwise, I need to write $tourdate and $availtix into a table (for EVERY instance of each $tourdate in haunted.