Jump to content

Help with ORDER a result


alexguz79

Recommended Posts

Hey everybody, i'm building a website for the softball league i play in.... so far the website is pretty good... with all the stats and profiles.... i'm having a little problem with the ORDER of the leaders in the categories i have to calculate the result...

 

for example... avg. is the result of the total hits divided by the total number of at bats... both numbers are coming from the database... the problem comes when i have to order the leaders from first to last...

 

this is my php:

 

$sql = "select profile_id, SUM(total_hits) AS hitstotal, SUM(ab) AS abtotal from batters WHERE year = '2010' GROUP BY profile_id"; 

$cons = mysql_query($sql); 
	while ($result = mysql_fetch_array($cons)) {
		$sumaab = $resultad['abtotal']; 
		$sumahits = $resultad['hitstotal']; 
		$p_id = $resultad['profile_id'];
		$prom = round(($sumahits."") / ($sumaab.""),3);

 

that gives me all the batting averages for the players.

 

and here is my question:

how can i order that $prom result from first to last?

Link to comment
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.