Poll Problem

ForgeForge Senior MemberThe Royal RAM
[PHP]
<?

require("config.php");
$sqldb = "outpost_general";

$conn = mysql_connect("$sqlhost","$sqluser","$sqlpass");
$sdb = mysql_select_db("$sqldb");

$query = "SELECT * FROM site_polls ORDER BY poll_id DESC LIMIT 1";
$result = mysql_query($query); $array = mysql_fetch_array($result);
$poll_id = $array[poll_id];

$query = "SELECT * FROM site_polls WHERE poll_id='$poll_id'";
$result = mysql_query($query); $array = mysql_fetch_array($result);

$poll_id = $array[poll_id];
$poll_name = $array[poll_name];
$poll_question = $array[poll_question];
$poll_option1 = $array[poll_option1];
$poll_option2 = $array[poll_option2];
$poll_option3 = $array[poll_option3];
$poll_option4 = $array[poll_option4];
$poll_option5 = $array[poll_option5];
$option1_text = $array[poll_option1txt];
$option2_text = $array[poll_option2txt];
$option3_text = $array[poll_option3txt];
$option4_text = $array[poll_option4txt];
$option5_text = $array[poll_option5txt];
$poll_votes = $array[poll_votes];

if(session_is_registered(poll)){

print "<center>$poll_name</center>";
print "<center>$poll_question</center>";


if($poll_option1 != 0) {
$Poll_Percent1 = Round(($poll_option1 / $poll_votes) * 100) . "%";
} else {
$Poll_Percent1 = 0 ."%";
}


if($poll_option2 != 0) {
$Poll_Percent2 = Round(($poll_option2 / $poll_votes) * 100) . "%";
} else {
$Poll_Percent2 = 0 ."%";
}


if($poll_option3 != 0) {
$Poll_Percent3 = Round(($poll_option3 / $poll_votes) * 100) . "%";
} else {
$Poll_Percent3 = 0 ."%";
}


if($poll_option4 != 0) {
$Poll_Percent4 = Round(($poll_option4 / $poll_votes) * 100) . "%";
} else {
$Poll_Percent4 = 0 ."%";
}


if($poll_option5 != 0) {
$Poll_Percent5 = Round(($poll_option5 / $poll_votes) * 100) . "%";
} else {
$Poll_Percent5 = 0 ."%";
}

if($option1_text != ""){
print "<IMG src=\"images/poll_bar.gif\" width=\"$poll_percent1\"><br>$option1_text :: $poll_option1 Votes<br>\n";
}

if($option2_text != ""){
print "<IMG src=\"images/poll_bar.gif\" width=\"$poll_percent2\"><br>$option2_text :: $poll_option1 Votes<br>\n";
}

if($option3_text != ""){
print "<IMG src=\"images/poll_bar.gif\" width=\"$poll_percent3\"><br>$option3_text :: $poll_option1 Votes<br>\n";
}

if($option4_text != ""){
print "<IMG src=\"images/poll_bar.gif\" width=\"$poll_percent4\"><br>$option4_text :: $poll_option1 Votes<br>\n";
}

if($option5_text != ""){
print "<IMG src=\"images/poll_bar.gif\" width=\"$poll_percent5\"><br>$option5_text :: $poll_option1 Votes<br>\n";
}

print "<center><a href=\"polls.php\" class=\"other_link\">Other Polls</a></center>";

}
else {
print "<center>$poll_name</center>";
print "<center>$poll_question</center>";
print "<form action=\"poll.php?mode=vote&id=$poll_id\" method=\"POST\">";

if($option1_text != ""){
print "<input type=\"radio\" name=\"vote\" value=\"option1\">$option1_text<br>";
}

if($option2_text != ""){
print "<input type=\"radio\" name=\"vote\" value=\"option2\">$option2_text<br>";
}

if($option3_text != ""){
print "<input type=\"radio\" name=\"vote\" value=\"option3\">$option3_text<br>";
}

if($option4_text != ""){
print "<input type=\"radio\" name=\"vote\" value=\"option4\">$option4_text<br>";
}

if($option5_text != ""){
print "<input type=\"radio\" name=\"vote\" value=\"option5\">$option5_text<br>";
}

print "<input type=\"submit\" value=\"value\">";
print "</form>";
}

?>
[/PHP]

Thats the code that shows the vote form, or if a session has been registered, show the results. Quite nice code bit. One problem though, The votes that are entered are in the mySQL database. But it doesnt show it, It always shows 0 votes, when i knowed i entered a vote. cause i checked in phpmyadmin. Any ideas people?
Can fat people Go skinny Dipping?

Comments

Sign In or Register to comment.