I have some code that works fine for ranking my results. The only problem is that sometimes there are ties and the way my script works, it wont display a tie.
For example, team 1 has 50 pts. team 2 has 40 points. team 3 has 30 points. team 4 has 40 points. The output I need is:
- team 1
- team 2
- team 4
- team 3
But what I get is:
- team 1
- team 2
- team 4
- team 3
Here is my code. Any help is appreciated.
$db->sql_query("insert into ".$prefix."_tourn_results (results_id, div_id, sched_id, team_id, results_numfish, results_livefish, results_wgt, results_bigfish, results_penalty, results_netwgt, results_points) values (NULL, '$div_id', '$sched_id', '$team_id', '$results_numfish', '$results_livefish', '$results_wgt', '$results_bigfish', '$results_penalty', '$results_netwgt', '$results_points')");
// Set Ranks by Net Weight
$query2 = "SELECT results_id FROM ".$prefix."_tourn_results WHERE sched_id='$sched_id' ORDER BY results_netwgt DESC";
$result = mysql_query($query2);
$rank = 1;
while ($row = mysql_fetch_array($result)) {
$update = ("UPDATE ".$prefix."_tourn_results SET results_rank = $rank WHERE results_id = '{$row['results_id']}' ");
mysql_query($update);
$rank ++;
}