Thread: PHP: Sorteren na een sortering.
-
28-04-2004, 18:53 #1Approved 9-lifer
- Registered
- 11/11/03
- Location
- Kortessem
- Posts
- 512
- iTrader
- 0
- Mentioned
- 0 Post(s)
- Reputation
- 0/16
PHP: Sorteren na een sortering.
Hello,
Ff korte situatie schets:
users hebben x aantal punten. Diegene met de hoogste punten komen in tabel.
Nu als twee mensen dezelfde putnen hebben, moet diegene met het meeste aantal wins hoger komen te staan.
Dit is de code, maar hierin moet ik nog sorteren op meeste wins. en k vind nie echt een simpele oplossing :/PHP Code:$sql = mysql_query("SELECT user_id, user_name, user_wins, user_losses, user_played, user_points FROM $db_users ORDER BY user_points DESC LIMIT 3");
echo '
<table width="100%" border="0">';
$i=1;
while ($Array=mysql_fetch_assoc($sql))
{
echo '
<tr>
<td width="25%">'.$i.':</td>
<td width="75%">'.$Array[user_name].' ('.$Array[user_points].' points)</td>
</tr>';
$i=$i+1;
}
echo '
</table>
<p>Total matches played: '.$tot.'</p>
';
de var voor het aantal wins is $Array[user_wins]
GrtzLast edited by /\quila; 28-04-2004 at 18:55.
"Beat the machine that works in your head"no votes
-
-
28-04-2004, 18:58 #2Member
- Registered
- 25/07/02
- Location
- Brussel
- Posts
- 1,001
- iTrader
- 5 (100%)
- Mentioned
- 0 Post(s)
- Reputation
- 2/2
"...order by totaalpunten,totaal_wins;"
no votes
-
28-04-2004, 19:05 #3nu zal hij normaal eerst volgens punten ordenen en in die punten(dus als ze gelijk hebben) zullen ze per wins geordend worden(meeste vanboven)PHP Code:
<?$sql = mysql_query("SELECT user_id, user_name, user_wins, user_losses, user_played, user_points FROM $db_users ORDER BY user_points DESC,user_wins DESC LIMIT 3");
echo '
<table width="100%" border="0">';
$i=1;
while ($Array=mysql_fetch_assoc($sql))
{
echo '
<tr>
<td width="25%">'.$i.':</td>
<td width="75%">'.$Array[user_name].' ('.$Array[user_points].' points)</td>
</tr>';
$i=$i+1;
}
echo '
</table>
<p>Total matches played: '.$tot.'</p>
'; ?>
}
no votes
-
28-04-2004, 19:11 #4Approved 9-lifer
- Registered
- 11/11/03
- Location
- Kortessem
- Posts
- 512
- iTrader
- 0
- Mentioned
- 0 Post(s)
- Reputation
- 0/16
Oké, ik dacht da ge da nie kon in een query. Lol, heel simpel dus
THNX
"Beat the machine that works in your head"no votes
