Hi Laserlight,
Good explanations of JOIN--thanks.
I took the JOIN statement out for the moment since the second table's only function was to provide the primary table's siteID with the actual name of soccer game's location. The primary table has three records that I want to present to the user. The date, location, and the field (field being the grassy expanse that the kids actually play on, not a field in a record) . Ultimately, but not included in this question since I know how to do it, the user will be able to click on the generated hyperlink and see all the home and away games taking place on that particular date, location, field.
If a table has several records with the same date, location, field (for example 11/27/2010, West Park, Field #1 8:00 am; 1/27/2010, West Park, Field #1 10:00 am) and it is first on the sorted locations, it will show up on the report. But, if there is only one game (8:00 am), a blank record is printed. After that first record, other records with just one entry, will show up. Weird.
By the way, my original code used a WHILE loop. I changed this to a DO loop. The difference was with the WHILE loop, nothing was printed in the first instance. With the DO loop, a blank record was printed.
Here's the complete code:
$sql="SELECT gameDate, siteID, field
FROM master_game_sched
GROUP BY gameDate, siteID, field
ORDER BY siteID desc, field
LIMIT 1 , 100";
$result=mysql_query($sql, $link )or die(mysql_error($mysql));
;
echo "<table border=1>";
echo "<tr bgcolor='yellow' align='center'><td>Site</td><td>Date</td><td>Field #</td></tr>";
do {
echo "<tr><td align='right'>" .$row['siteID'] . " ";
echo "<td>" . convertDate($row['gameDate']) . "</td>";
echo "<td>" . $row['field'] . "</td></tr>";
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC));
echo "</table>";
Sample output ( the -- below is the first line of data. There is nothing there, but the -- appears because I have a function that turns the date (2001127 into 11-27-2010)
Site Date Field #
--
11 11-27-2010 1
11 11-27-2010 2
11 11-26-2010 3
11 11-28-2010 4
And the schema (in DESC order)
gameID whatDiv gameDate gameTime flight siteID field home away
310 10B 20101126 09:00:00 12 1
307 19G 20101128 14:00:00 11 4 D B
308 19G 20101128 15:00:00 11 4 B D
309 19G 20101128 16:00:00 11 4 A C