I'm trying to create a list of Rosters all on one page from a data table. I want each roster to show its Team Number ($team) and coaches name ($nameCoach) at the top of the list. I tried moving the Foreach loop around, but I can't get the results I want.
So it should look like:
A1 - Coach Brett Crist
player name
player name
player name
etc
A2 - Coach Paul Goser
player name
player name
etc
Here is the link to the page. Basically, for each player it lists all the coaches.
http://metroindybasketball.com/resources/league2012/2012rosters.php
$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)) { if($currentTeam != $coach) { foreach ($coach as $team=>$nameCoach) { //Status has changed, display status header $currentTeam = $line['2012team']; echo '<tr><td colspan="6"><hr></td></tr> <tr><td colspan="6"><span class="coach">'. $team . ' - ' .$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>';