DarkPrince2005 Posted September 20, 2009 Share Posted September 20, 2009 I've got a graph, that ii want to order the graph percentage by desc. Can anyone help? mysql_connect("localhost","root",""); mysql_select_db("db"); $max = 0; $sql2=mysql_query("select * from elected where day_no not like '-1'"); while ($valid_list = mysql_fetch_array($sql2)){ $cnt = 0; $sql = "SELECT COUNT(elected_id) AS 'RCNT' FROM voters where elected_id like '$valid_list[elected_id]' order by COUNT(elected_id) desc"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); $value = $myrow["RCNT"]; if ($result) { $votes[$value]=$cnt ; if ($cnt > $max) { $max = $cnt; }//end if $l=mysql_query("select sum(vote_count) as 'total' from elected"); $r=mysql_fetch_assoc($l); $total = $r["total"]; } else { $votes[$value] = 0; }//end if echo " <tr>\n"; echo " <td align=center>$valid_list[elected_id]</td>\n"; echo " <td align=center><img src='../$valid_list[img_path]' height='40'></td>\n"; $p = number_format((($myrow["RCNT"] / $total) * 100), 2, ".", ","); $w = (200 * ($p / 100)); echo " <td align=center>$value</td>\n"; echo " <td align=left><img src='1x1.jpg' width='" . $w . "px' height='10px' border=0>" . $p . "%</td>\n"; echo " </tr>\n"; echo "<br />";}//next //next Link to comment https://forums.phpfreaks.com/topic/174882-solved-ordering/ Share on other sites More sharing options...
DarkPrince2005 Posted September 20, 2009 Author Share Posted September 20, 2009 Nevermind, solved it... Sometimes ppl just don't think....lol!!!! $sql2=mysql_query("select * from elected where day_no not like '-1' order by vote_count desc"); Link to comment https://forums.phpfreaks.com/topic/174882-solved-ordering/#findComment-921648 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.