Hello again
This is what I came up with. I am sure fault will be found in it, but it was all I could think of in order to print each state and then all the teams under each, BY state
Code:
function teams() {
$page = "<h3>Show Team</h3>\n";
$page .= "<table id=\"info\">\n";
$year = '2011';
$statequery = doquery("SELECT DISTINCT " .
"ws_stats.state, " .
"ws_state.id, ws_state.state " .
"FROM ws_stats " .
"INNER " .
"JOIN ws_state " .
"ON ws_state.id = ws_stats.state " .
"WHERE ws_stats.year = '".$year."'" .
"ORDER BY ws_state.state", "stats");
while ($state = mysql_fetch_array($statequery)) {
$page .= "<tr><td>".$state["state"]."</td></tr>\n";
$schoolquery = doquery("SELECT DISTINCT " .
"ws_stats.school, ws_stats.state, " .
"ws_school.school, ws_state.state " .
"FROM ws_stats " .
"INNER " .
"JOIN ws_school " .
"ON ws_school.id = ws_stats.school " .
"INNER " .
"JOIN ws_state " .
"ON ws_state.id = ws_stats.state " .
"WHERE ws_stats.state = '".$state["id"]."'" .
"ORDER BY ws_school.school", "stats");
$count = 0;
while ($school = mysql_fetch_array($schoolquery)) {
if ($count == 0 ) { $page .= "<tr>"; }
$page .= "<td width=\"150\">".$school["school"]."</td>";
if ($count % 3 ) { $page .= "</tr>\n"; }
$count++;
}
}
if (mysql_num_rows($statequery) == 0) { $page .= "<tr class=\"alt\"><td>No teams found.</td></tr>\n"; }
$page .= "</table>";
admindisplay($page, "Teams");
}
It works okay, but I may have to move over to another forum to figure out how to make the second WHILE statement with the Modulo print out the closing </tr>'s.
I keep getting this source output, a missing </TR> before the last <TABLE>
Code:
<divid="content">
<h3>Show Team</h3>
<tableid="info">
<tr><td>California</td></tr>
<tr><tdwidth="150">Eastside</td><tdwidth="150">Westside</td></tr>
<tr><td>Kentucky</td></tr>
<tr><tdwidth="150">Oak Ridge</td></table>
</div>
Bookmarks