Calculating Percentage Help?
Posted: Sat Mar 22, 2008 4:13 pm
Hey guys having a bit of trouble with by flash back end (mySQL) and was wondering if you could share the wisdom?
I always feel illustration helps so heres my table...(called war)...dont ask
war_id | times_selected
1 | 5
2 | 3
3 | 9
4 | 17
5 | 3
Basically I need to select the highest value of times_selected (17 for example but is actually a counter updated from flash) and find its percentage to return along with its "war_id (4)
My psudeo code was along the lines of
-----
SELECT SUM(times_selected) as "Total"
FROM war
($Highest value of times_selected / "Total" x 100 = $var
PRINT $highest value war_id, $var (its percentage)
-----
As you can tell im not too hot with the PHP/mySQL right now and have been pouring over syntax combinations on and off for a while with no success. Also the print is to return it to flash as im sure you know.
Any help would be greatly appreciated.
Jason
I always feel illustration helps so heres my table...(called war)...dont ask
war_id | times_selected
1 | 5
2 | 3
3 | 9
4 | 17
5 | 3
Basically I need to select the highest value of times_selected (17 for example but is actually a counter updated from flash) and find its percentage to return along with its "war_id (4)
My psudeo code was along the lines of
-----
SELECT SUM(times_selected) as "Total"
FROM war
($Highest value of times_selected / "Total" x 100 = $var
PRINT $highest value war_id, $var (its percentage)
-----
As you can tell im not too hot with the PHP/mySQL right now and have been pouring over syntax combinations on and off for a while with no success. Also the print is to return it to flash as im sure you know.
Any help would be greatly appreciated.
Jason