karimali831 Posted September 22, 2010 Share Posted September 22, 2010 Hi, I am using multiple rows in my table and I want to order it in ascending order from a column. With SQL statement it is simple as saying ORDER BY column but how I can do this with just numbers? So I want for example: (goes in correct order) Col 1 Col 2 Col3 # 5 # # 43 # # 87 # # 113 # instead of: Col 1 Col 2 Col3 # 113 # # 43 # # 87 # # 5 # Thanks for any help!! Link to comment https://forums.phpfreaks.com/topic/214115-ordering-table/ Share on other sites More sharing options...
ngreenwood6 Posted September 22, 2010 Share Posted September 22, 2010 "SELECT * FROM col2 WHERE something = 'something' ORDER BY col2 ASC" Link to comment https://forums.phpfreaks.com/topic/214115-ordering-table/#findComment-1114186 Share on other sites More sharing options...
karimali831 Posted September 22, 2010 Author Share Posted September 22, 2010 I want to order by XP, this is not a column though in my first query: Example: echo ' <table width="100%" bordercolor="'.$border.'"> <tr> <td width="25%" align="left" class="title" colspan="12"><a name="standings"></a> • '.getladname($laddID).' Standings</td> </tr> <tr> <td width="5%" bgcolor="'.$bg1.'" class="title2" align="center">Rank:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Teamname:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">CR:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">XP:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Won:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Draw:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Lost:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Streak:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Reg:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Ratio:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Challenge:</td> </tr>'; $rank = 1; $participants = safe_query("SELECT * FROM ".PREFIX."cup_clans WHERE ladID='$laddID' AND 1on1='0' ORDER BY credit DESC"); while($ds=mysql_fetch_array($participants)) { $teamID = $ds['clanID']; $ladmatches = safe_query("SELECT SUM(score1) as totalpoints FROM ".PREFIX."cup_matches WHERE ladID='$laddID' AND clan1='$teamID' AND (clan1 != '0' AND clan2 != '0') AND (clan1 != '2147483647' AND clan2 != '2147483647') AND confirmscore='1' AND einspruch='0'"); $tp1=mysql_fetch_array($ladmatches); $challenger_totalpoints = $tp1['totalpoints']; $xp_points = $challenger_totalpoints+$added_xp; if(empty($xp_points)) $xp = 0; else $xp = $xp_points; echo ' <tr> <td bgcolor="'.$bg1.'" width="5%" align="center">#'.$rank.'</td> <td bgcolor="'.$bg1.'" align="center">'.getusercountry($teamID).' <a href="?site=profile&id='.$teamID.'">'.getnickname($teamID).'</a></td> <td bgcolor="'.$bg1.'" align="center">'.$ds['credit'].'</td> <td bgcolor="'.$bg1.'" align="center">'.$xp.'</td> <td bgcolor="'.$bg1.'" align="center">'.$won.'</td> <td bgcolor="'.$bg1.'" align="center">'.$draw.'</td> <td bgcolor="'.$bg1.'" align="center">'.$lost.'</td> <td bgcolor="'.$bg1.'" align="center">'.$streak.'</td> <td bgcolor="'.$bg1.'" align="center">'.returnTime($ds['registered']).'</td> <td bgcolor="'.$bg1.'" align="center">'.$ratio.'%</td> <td bgcolor="'.$bg1.'" align="center">'.$new_challenge.'</td> </tr> <br>'; Link to comment https://forums.phpfreaks.com/topic/214115-ordering-table/#findComment-1114212 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.