Posted on Sunday 9th November 2008 at 07:17 PM | |
jambomb Junior Member |
Ok i have big problems trying to order my database, im making a hall of fame and so far its working but just not ordering the users level in order this is my code Code $get_users = mysql_query("SELECT * FROM `members` ORDER BY `level` DESC); $class1 = "#333333"; $class2 = "#1E1E1E"; $class = $class1; $m = "1"; { while($user = mysql_fetch_array($get_users)) { echo ("<table width=\"75%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td align=\"center\" width='20%' bgcolor=\"$class\">$m</td> <td align=\"center\" width='24%' bgcolor=\"$class\"><a href='members.php?user=$online[username]'>$user[id]</a></td> <td align=\"center\" width='36%'bgcolor=\"$class\"><a href='gang/view_gang.php?view=$user[gangname]' class='tag'>$user[gangtag]</a> <a href='members.php?user=$user[username]'>$user[username]</a></td> <td align=\"center\" width='20%' bgcolor=\"$class\">$user[level]</td> </tr> </table>"); if($class == $class1){ $class = $class2; }else{ $class = $class1; } $m++; } } |
Posted on Sunday 9th November 2008 at 11:27 PM | |
Matt Newbie |
you're going the wrong way about this. you can also do this with for() and foreach() but hers a function i use: PHP Code
1 2 3 4 5 6 7 8 9
<?php
to use it: PHP Code
1 2 3 4 5 6 7 8
<?php
|
Posted on Sunday 9th November 2008 at 11:42 PM | |
jambomb Junior Member |
the colours fine mate, but its just the Ordering what isnt right doesnt DESC Propaly |
Posted on Monday 10th November 2008 at 06:39 AM | |
Matt Newbie |
sorry man, actually, your code should be returning an error, since you have: $get_users = mysql_query("SELECT * FROM `members` ORDER BY `level` DESC); there should be a last " ad the end of desc. $get_users = mysql_query("SELECT * FROM `members` ORDER BY `level` DESC"); try that. |
Posted on Monday 10th November 2008 at 10:56 AM | |
jambomb Junior Member |
yeh it works man but just doesnt order! :S go on www.crime-network.com and register mate then go to the city then Hall of Fame then you will know what im on about :) thanks x |
Posted on Tuesday 11th November 200 at 01:28 PM | |
Dava Active Member |
change it to $get_users = mysql_query("SELECT * FROM `members` ORDER BY `level` ASC"); |
Posted on Tuesday 11th November 200 at 01:34 PM | |
jambomb Junior Member |
okay that works good coz on this page http://www.crime-network.com/main/hall_of_fame.php?page=73 its ordered correct... but i need it so its highest first if u understand xD thanks for help so far!! |
Posted on Tuesday 11th November 200 at 04:09 PM | |
Matt Newbie |
change ASC back to DESC just to see if anything happens, because that should work 100%, there's no reason why that shouldn't work. |
Posted on Tuesday 11th November 200 at 06:24 PM | |
jambomb Junior Member |
It kinda works.. but im level 9 and its missed me out lol and gone to 8, 5, 2 2 2 2 etc... :S but it kinda working :S rofl dno why its fucked up tho |
Posted on Tuesday 11th November 200 at 11:16 PM | |
Dava Active Member |
it wouldnt just miss out a row u must be a lower level |