|
Posted by Ja NE on 10/25/05 13:08
I need to sort some values by percentage, and don't know how...
here is where I got so far:
mysql_query("SELECT sum($usage)...
list($total)... // now I have total number I need to find %
mysql_query...
while(list($id,$usage) = mysql_fetch_array)) {
mysql_query("SELECT sum($usage) WHERE id=$id...
list($used)... // now I have some usage for each $id
$made = sprintf("%.f", $used / $total * 100);
echo"$id $made<br>"; //will output:
101 @ 50.38%
102 @ 25.19%
103 @ 24.43%
and I want to deal with the last only from this example. with the one of
smallest percentage and I can't know which one will that be.
I think I have to create and sort array, but whatever I have made, I had
no success.
if I create array inside of while{} I end with 3 different arrays.
if I end while {} I have only one to work with...
can anyone help me? (I have avoided arrays so far with "great" success,
but from now on, I just have to use them and I don't understood them at
all. my english isn't that good, and haven't find proper documentation
on my language to learn)
tnx in advance
--
Ja NE
http://fotozine.org/?omen=janimir
--
Navigation:
[Reply to this message]
|