We help IT Professionals succeed at work.
Get Started

showing multiple images for the poll output

mattibutt asked
Last Modified: 2013-12-12
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))
	$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);
				$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";

Open in new window

Watch Question
Most Valuable Expert 2011
Author of the Year 2014
This problem has been solved!
Unlock 1 Answer and 24 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE