Arrays are sure confusing. I've done a bunch of reading, but still don't get it.
Here's the data stored in the table--there are three fields: siteID, gameTime and team:
site time team
1 8:00 am 3-1
2 7:45 am 2-4
3 8:00 am 5-8
4 7:00 am 7-6
I want to create a report that has the following
Site 1 8:00 am 3-1 ||Site 2 7:45am 2-4 || Site 3 8:00 am 5-8 || Site 47:00am 7-6
Because I sorted the records in the the table by gameTime then siteID, when I print the record, I end up with the following:
Site 1 7:00am 7-6 || Site 2 7:45am 2-4 || Site 3 8:00 am 3-1 || Site 48:00 am 5-8
Because it sorts by time first, It puts site 4's information in site 1's column.
Since every row has four columns, and the records contain the siteID, I thought I'd stick everything in an array and sort the array on the siteID, printing them out in groups of four (since there are four sites). But I can't get it to sort right or figure out how to print it out in groups of four. I tried all the obvious sorts (ksort, array_multisort) but nothing jumps out.
Here are snippets of the code:
$sql = 'SELECT * FROM `master_game_sched` '
. ' WHERE `siteID` = 3 && gameDate = 20110409'
. ' Order By gameTime, siteID';
I put stuff into an array using this:
$slot[]= $row['field'];
$slot[]=$row['gameTime'];
$slot[]=$row['gameID'];
I'm still shaky on how best to extract the data. I can see its there with print_r. I assume I should use a foreach...?
foreach ($slot as $value) { echo "$value <br/>";}
Direction and explanations--suggestions, etc, are all gratefully accepted.