Jump to content

[SOLVED] Order by value of "money"


Zoroaster

Recommended Posts

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>';
}
}





?>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.