HIgh score not up to scratch

From: Date: Thu, 16 Mar 2006 01:53:47 +0000
Subject: HIgh score not up to scratch
Groups: php.general 
Request: Send a blank email to php-general+get-231990@lists.php.net to get a copy of this message
Any help Here: At the moment this shows a USERNAME-COMPETITION and POINTS for a user with the highest points out of many competitions. The USERS also have a second points field (acc_margin) where lower score is better. So my problem is that i need to show the highest scoring user (by points) then if there is another user with the exact same points then the user with the lowest (acc_margin) is shown. <?php for ($x=1; $x<=$no_comps; $x++) { $max_query[$x] = mysql_result(mysql_query("SELECT MAX(points) as Num FROM leaderboard WHERE comp_id = $comp_ids[$x]"),0); //get name $query4 = @mysql_query("SELECT username FROM leaderboard WHERE points = " . number_format($max_query[$x],0) . " AND comp_id = $comp_ids[$x]"); $result4 = @mysql_fetch_array($query4); $leader[$x] = $result4['username']; //get comp name $query5 = @mysql_query("SELECT name FROM comps WHERE id = $comp_ids[$x]"); $result5 = @mysql_fetch_array($query5); $comp[$x] = $result5['name']; echo "<tr class=tdb1><td>" . $leader[$x] . "</td><td>" . $comp[$x] . "</td><td align=center>" . number_format($max_query[$x],0) . "</td></tr>"; } ?> HERE IS THE TABLE: Field Type Null Default id int(11) No user_id int(11) No 0 comp_id int(11) No 0 username text No points int(11) No 0 amt float No 0 margin int(11) No 0 acc_margin int(11) No 0 **************************** I had a similar question earlier that i was helped with but i cant seem make it work here: (here it is) SELECT * FROM leaderboard WHERE comp_id = $comp_id ORDER by points DESC, acc_margin ASC *******************************

« previous php.general (#231990) next »