Jump to content

Complicated ordering...


TEENFRONT

Recommended Posts

Hey

 

il jump straight in, im confused with a way to order some results... heres the stuff..

 

$result = mysql_query("SELECT * FROM teams");

 

OK so that selects everything from the table teams (obiously lol)

 

while($row = mysql_fetch_array($result)) {

$played = $row['played'];
$won = $row['won']
$teamname = $row['teamname'];

$rating = round($won /($played /100)); // works out rating out of 100 from games played to games won.

echo "$teamname - $rating";  // EG output: "Team1 - 70"

  }

 

ok so that runs the while loops, and gets the team info, and applies a rating for them..but you know what im gunna ask lol, i want to order the results by the rating value..but the rating value isnt found untill after the query, so, how do i add the rating math to an order by value? so right now it outputs this.

 

 

Team1  - 70

Team2 - 60

Team3 - 88

Team4 -75

 

i obviously want it like this

 

Team3 - 88

Team4 - 75

Team1 - 70

Team2 - 60

 

Id really love any help, iv been up for a few hours....now i have a headache lolol.

Link to comment
https://forums.phpfreaks.com/topic/132822-complicated-ordering/
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.