Woodburn2006 Posted September 8, 2007 Share Posted September 8, 2007 im doing a website for a university football team and want to be able to list the fixtures in blocks of the team. i use this code to get the fixtures from the database: SELECT * FROM fixtures ORDER BY team, month, date how can i do it so that the first team fixtures are in one block, the second team is in one block etc etc. so that hopefully it will look something like this: First Team 1/1 Man Utd 2/1 Chelsea 3/10 Arsenal Second Team 2/4 Bolton 6/7 Derby etc etc Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 8, 2007 Share Posted September 8, 2007 First Team 1/1 Man Utd 2/1 Chelsea 3/10 Arsenal Second Team 2/4 Bolton 6/7 Derby We'll need a lot more description that you've given in order to understand what that output is meant to be about. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 8, 2007 Share Posted September 8, 2007 if we assume this is a list of team name followed by list of dates for the that team, you'd SELECT * FROM fixtures ORDER BY team, month, date Then loop over the results, keeping track of the current team, for instance: $current_team = ""; while ($line = mysql_fetch_assoc($result)) { $team = $line['team_name']; $t_date = $line['team_date']; if ($team != $current_team) { if ($current_team > "") { echo "<P>"; // Paragraph break between teams } echo "$team<BR>"; $current_team = $team; } echo "$t_date<BR>"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.