<?php 
 require('common.php');
 function DisplayPoll() { 
  connectdb();
  mysql_select_db(pollbooth);
  $sql = "select choice from choices";
  $query = mysql_query($sql);
  $num_of_voting_choices = mysql_num_rows($query); 
  
  $sql = "select choice from votes";
  $query = mysql_query($sql);
  $number_of_votes = mysql_fetch_array($query);
  for ($i = 0; $i < $num_of_choices; ++$i) { 
    $sql = "select id from votes where choice='$i'";
    $query = mysql_query($sql);
    $num_of_rows_for_choice = mysql_num_rows($query);
    $choice_percentage = "$number_of_rows_for_choice / $number_of_votes";
    $number_of_pixels_to_print = "$choice percentage / 5";
    for ($x = 0; $x < $number_of_pixels_to_print; ++$x) { 
     echo("<img src="."$color_choice".">");
     echo(" "."$choice_percentage"."\%");
    }
   }
   
  } 
  ?>   

Please help :)

Reply via email to