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
https://forums.phpfreaks.com/topic/216784-help-with-order-a-result/
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.