Jump to content

Help With First Poll System


ShoeLace1291

Recommended Posts

Ok, I'm trying to make a poll system, it's not quite working correctly.  I have three MySQL tables polls, options, and votes.

 

polls table:

pollID

pollQuestion

pollVotes

pollDate

 

pollOptions table:

optionID

pollID

optionName

optionVotes

 

pollVotes table:

voteID

optionID

userID

pollID

 

My problem is, I can't figure out why the question is being displayed in front of each option's result.  For example, the poll's question is What do you think of the brand new site?  Options are "I love it!", "Pretty good", "Not sure", and "I hate it!".  This poll displays as this:

pollresultspf7.jpg

 

I'm trying to be as clear as I can... lol.  This is my code to display the results:

  	  $query = mysql_query("SELECT * FROM sg_pollOptions WHERE pollID = '$pollID'") or die("Error: ".mysql_error());
	  while($fetch=mysql_fetch_array($query)){
	  			$optionID=$fetch["optionID"];
	  			$optionName=$fetch["optionName"];
				$optionVotes=$fetch["optionVotes"];
			$query2 = mysql_query("SELECT * FROM sg_polls WHERE pollID = '$pollID'") or die("Error: ".mysql_error());
			$fetch = mysql_fetch_array($query2);
					$pollQuestion=$fetch["pollQuestion"];
			$pollVotes = mysql_num_rows($query2);
					$optionPercent = $optionVotes % $pollVotes;
			$pollResults = "<td align='right'>$optionName</td>
						   	<td align='left'><img src='themes/Popular Gaming/poll_result.gif' width='$optionPercent%' alt='$optionPercent %'></td>";
			$temps = array(
				   	 	   'POLL_QUESTION' => $pollQuestion,
						   'POLL_RESULTS' => $pollResults
						   );
				$templateFile = "themes/Popular Gaming/pollresults_body.tpl";
				$pollresults = buildTemplate($templateFile, $temps);
				echo $pollresults;
		}

 

Any help would be greatly appreciated. :)

Link to comment
https://forums.phpfreaks.com/topic/98106-help-with-first-poll-system/
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.