توليد صور الفصل 19
السرد 19-5-4) showpoll.php - الجزء 4 يرسم البيانات الفعلية ثم يُنهي البرنامج
476
/***********************
Draw data into graph
******
*******/
// Get each line of db data and draw corresponding bars while ($row = mysql_fetch_object ($result))
}
if ($total_votes > 0)
$percent
else
intval(round(($row->num_votes/$total_votes)*100));
$percent = 0;
// display percent for this value
ImageTTFText($im, $main_size, 0, $width-30, $y+($bar_height/2),
$percent_color, $font, $percent."%");
if ($total_votes > 0)
$right_value = intval(round(($row->num_votes/$total_votes)*100));
else
$right_value = 0;
// length of bar for this value
$bar_length
=
$x + ($right_value* $bar_unit);
// draw bar for this value
ImageFilled Rectangle($im, $x, $y-2, $bar_length, $y+$bar_height, $bar_color);
// draw title for this value
ImageTTFText($im, $main_size, 0, $text_indent, $y+($bar_height/2), $text_color, $font, "$row->candidate");
// draw outline showing 100%
ImageRectangle($im, $bar_length+1, $y-2,
($x+(100*$bar_unit)), $y+$bar_height, $line_color);
// display numbers
ImageTTFText($im, $small_size, 0, $x+(100*$bar_unit)-50, $y+($bar_height/2), $number_color, $font, $row->num_votes."/".$total_votes);
// move down to next bar
$y=$y+($bar_height+$bar_spacing);
/******
Display image
**********
*******************************************/
Header("Content-type:
ImagePng($im);
/************
Clean up
*****************
ImageDestroy ($im);
image/png");
***********
*******/
?>
ص٤٦٠