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
https://forums.phpfreaks.com/topic/173269-solved-order-by-value-of-money/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.