I can never really get my head wrapped around arrays and keys, and in this instance, I'm not sure a "foreach" loop helps me (or at least helps me without rewriting code).
Here is the page in question:
http://metroindybasketball.com/resources/league2012/2012rosters.php
What I want it to do is, where you see A1, A2, A3, etc, I want it to say:
A1 - Coach Brett Crist
A2 - Coach Paul Gosser
etc
Here is my code: (Where it says $nameCoach, that's just sort of a place holder at the moment to keep it from showing errors. I've tried several things there, including messing with key() and current().)
echo '<div class="roster"><table width="500">
<thead>
<tr>
<th>#</th>
<th>Team - Coach</th>
<th>HT</th>
<th>GR</th>
<th>City (School)</th>
<th>College</th>
</tr>
</thead>
<tbody>
';
$coach = array (
'A1' =>'Coach Brett Crist',
'A2' =>'Coach Paul Gosser',
'A3' =>'Coach Brian Tonsani',
'B1' =>'Coach Dustin Harvey',
'B2' =>'Coach Kyle Smith',
'B3' =>'Coach Trevor Andershock',
'C1' =>'Coach Jim Reamer',
'C2' =>'Coach Aaron Butcher',
'C3' =>'Coach Bob Cerbone',
'D1' =>'Coach Larry Baker',
'D2' =>'Coach John Tate',
'D3' =>'Coach Victor Stallworth',
'E1' =>'Coach Mark Bailey',
'E2' =>'Coach Angelo Smith',
'E3' =>'Coach Mike Lawson',
'E4' =>'Coach Jeremy Tiers',
'F1' =>'Coach Aaron Butcher',
'F2' =>'Coach Duke Pryor',
'F3' =>'Coach Damon Hawkins',
'F4' =>'Coach Roy Hairston',
'G1' =>'Coach Kristof Kendrick',
'G2' =>'Coach Michael Tucker',
'G3' =>'Coach Kenton Granger',
'G4' =>'Coach Steve Turner',
'H1' =>'Coach Seve Beach',
'H2' =>'Coach Matt Lacey',
'H3' =>'Coach Derrick Gentry',
'H4' =>'Coach Kayle Funkhouser',
'I1' =>'Coach Courtney James',
'I2' =>'Coach Barry Kroot',
'I3' =>'Coach Chris Hawkins',
'J1' =>'Coach Chris Sibila',
'J2' =>'Coach Larry Baker',
'J3' =>'Coach Dan Schukraft'
);
$query = 'SELECT * FROM fallLeague10 WHERE 2012team IS NOT NULL ORDER BY 2012team,2012number';
$results = mysql_query($query) //or trigger_error('MySQL error: ' . mysql_error())
;
$currentTeam = false;
while($line = mysql_fetch_assoc($results)) {
$coach = $line['2012team'];
if($currentTeam != $coach)
{
//Status has changed, display status header
$currentTeam = $line['2012team'];
echo '<tr><td colspan="6"><hr></td></tr>
<tr><td colspan="6"><span class="coach">'. $coach . ' - ' .$nameCoach. '</td></tr>
';
}
echo '<tr>
<td>' . $line['2012number'].'</td>
<td><b>' . $line['nameFirst'] . ' ' . $line['nameLast'] . '</b></td>
<td><center>'. $line['feet'] . '\'' . $line['inches'] . '"</center></td>
<td><center>'. $line['grade'] . '</center></td>
<td>'. $line['school'] . '</td>';
echo '<td><b>'. $line['college'].'</b></td>';
echo '</tr>';}
echo '</tbody></table>';