JJohnsenDK Posted January 23, 2007 Share Posted January 23, 2007 HeyI was wondering if its possible to order by or limit by a specific colum. I have a football table/league table with 12 teams and one of those teams are "my team". I want to make a "mini" league table where i only show 6 of the teams but "my team" has to be in the middle, so it doesnt mather if "my team" is in the 1 place or in the 10 place, it will allways apear as one of the 6 teams. Like this4. "My team"5. Viborg6. Aab7. OB8. FCK9. BrøndbyOR7. OB8. FCM9. FCN10. FCK11. Vejle12. "My Team"Here is the code im using now. It only shows top six of the table no mather where "my team" is placed in the table:[code]<table> <tr> <td width='100'><b>Klub</b></td> <td width='30' align='center'><b>K</b></title></td> <td width='30' align='center'><b>P</b></td> </tr> <tr> <td colspan='3'><img src='images/black.jpg' width='100%' height='1'></td> </tr> <?php $sql2 = "SELECT league.team_id, league.rounds, league.points, league.season, team.name FROM league INNER JOIN team ON league.team_id = team.team_id WHERE league.season = '2006' ORDER BY league.points DESC LIMIT 6"; $result2 = mysql_query($sql2); while($row2 = mysql_fetch_array($result2)){ ?> <tr> <td><?=$row2['name']; ?></td> <td align='center'><?=$row2['rounds']; ?></td> <td align='center'><?=$row2['points']; ?></td> </tr> <tr> <td colspan='3'><img src='images/black.jpg' width='100%' height='1'></td> </tr> <?php } ?> <tr> <td colspan='3' align='right'><a href='sasliga.php'>mere></a></td> </tr> </table>[/code] Link to comment https://forums.phpfreaks.com/topic/35385-order-by-or-limit-by-specific-colum/ Share on other sites More sharing options...
michaellunsford Posted January 23, 2007 Share Posted January 23, 2007 you could [color=red]ORDER BY league.id='somevalue',league.points DESC[/color] but your team would always be first on the list -- the remaining teams would be sorted in order of points. "somevalue" would be a value representing your team. Link to comment https://forums.phpfreaks.com/topic/35385-order-by-or-limit-by-specific-colum/#findComment-167314 Share on other sites More sharing options...
JJohnsenDK Posted January 23, 2007 Author Share Posted January 23, 2007 Aaah allright, i guess i can live with that. Thanks for helping out :D Link to comment https://forums.phpfreaks.com/topic/35385-order-by-or-limit-by-specific-colum/#findComment-167328 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.