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 Link to comment https://forums.phpfreaks.com/topic/68503-displaying-ordered/ 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. Link to comment https://forums.phpfreaks.com/topic/68503-displaying-ordered/#findComment-344387 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>"; } Link to comment https://forums.phpfreaks.com/topic/68503-displaying-ordered/#findComment-344393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.