troubleshooting Question

showing multiple images for the poll output

Avatar of mattibutt
mattibuttFlag for United States of America asked on
PHPScripting Languages
24 Comments1 Solution234 ViewsLast Modified:
hi
i have a poll which displays poll results using one image, i want to have couple of different images for result display
function print_results($poll_id)
{
	global $tapps_dir;
	global $tapps_pollbar_image_max_width;
 
	if (isset($tapps_pollbar_image_max_width))
		$barmaxwidth=$tapps_pollbar_image_max_width;
	else
		$barmaxwidth=128;
 
	$result = mysql_query("SELECT * FROM tapps_polls WHERE poll_id=$poll_id");
	$poll = mysql_fetch_object($result);
 
	if ($poll)
	{
		echo "<b>$poll->title</b><br>\n";
		echo "<br>\n";
		echo "$poll->description<br>\n";
		echo "<br>\n";
 
		$result = mysql_query("SELECT SUM(counter) AS sum_counter FROM tapps_votes WHERE poll_id=$poll_id");
		$o = mysql_fetch_object($result);
		$sum_counter = $o->sum_counter;
 
		$result = mysql_query("SELECT MAX(counter) AS max_counter FROM tapps_votes WHERE poll_id=$poll_id");
		$o = mysql_fetch_object($result);
		$max_counter = $o->max_counter;
 
		$result = mysql_query("SELECT option_text,counter FROM tapps_votes WHERE poll_id=$poll_id ORDER BY option_id");
 
		echo "<table cellpadding=0 cellspacing=4>\n";
 
		while ($row = mysql_fetch_object($result))
		{
			echo "<tr>\n";
			echo "<td>$row->option_text</td>\n";
			if ($row->counter > 0)
			{
				$p = (float)(100*$row->counter/$sum_counter);
				$w = (int)($barmaxwidth*$row->counter/$max_counter);
			}
			else
			{
				$p = 0;
				$w = 1;
			}
			$s = strip_tags($row->option_text);
			echo "<td><img src=\"".$tapps_dir."poll_bar.jpg\" height=15 width=$w alt=\"$s\"></td>\n";
			printf("<td>%.1f %% (%d)</td>\n", $p, $row->counter);
			echo "</tr>\n";
		}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 24 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 24 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros