Jump to content

[SOLVED] Ordering?


DarkPrince2005

Recommended Posts

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

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.