Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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