Zoroaster Posted September 5, 2009 Share Posted September 5, 2009 Hey guys. I've made a list of the usernames with their amount of money next to them. I've also managed to make the ones with money appear at the top and the ones without money will appear at the bottom. However, the players aren't ordered by the value of money, only the fact that they have money. If you have any idea of how I can make them appear in the order of the value of their money, that'd be great. Here's the code: <?php session_start(); if(!session_is_registered(myusername)) { header("location:index.php"); } echo '<html>'; echo '<body>'; echo '<br>'; echo '<br>'; echo '<br>'; echo '<table border="2" bgcolor="#339933" align="center" width="66%"> '; echo '<tr>'; echo '<b><center>Username And Money</b></center>'; echo '</tr>'; echo '</table>'; echo '</body>'; echo '</html>'; $connect = mysql_connect("localhost","zoroaste","***"); mysql_select_db("zoroaste_test1"); $sql4 = "SELECT * FROM Login ORDER BY `Login`.`money` DESC LIMIT 0 , 300 "; $query = mysql_query($sql4); while($row = mysql_fetch_array($query)) { $uusername = $row['username']; $money = $row['money']; $c = array($money => $uusername); foreach ($c as $key1 => $username1){ echo '<html>'; echo '<body bgcolor="#0000CC">'; echo '<table border="2" bgcolor="#339933" align="center" width="66%">'; echo '<tr>'; echo '<td width="50%">'; echo '<center>'; echo $username1; echo '</center>'; echo '<br />'; echo '</td>'; echo '<td>'; echo '<center>'; echo $money; echo '</center>'; echo '<br />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</body>'; echo '</html>'; } } ?> Quote Link to comment Share on other sites More sharing options...
bundyxc Posted September 5, 2009 Share Posted September 5, 2009 So, are you trying to sort? Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted September 5, 2009 Share Posted September 5, 2009 So what datatype is the money column in your database table? Quote Link to comment Share on other sites More sharing options...
Zoroaster Posted September 5, 2009 Author Share Posted September 5, 2009 So what datatype is the money column in your database table? Thanks Mark Baker. I forgot to change the money column to INT. Silly me 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.