get_results("SELECT * FROM $wpdb->pollsq ORDER BY id DESC"); $answers = $wpdb->get_results("SELECT aid, qid, answers, votes FROM $wpdb->pollsa ORDER BY votes DESC"); foreach($questions as $question) { $polls_questions[] = array('id' => intval($question->id), 'question' => stripslashes($question->question), 'timestamp' => $question->timestamp, 'total_votes' => intval($question->total_votes)); } foreach($answers as $answer) { $polls_answers[] = array('aid' => intval($answer->aid), 'qid' => intval($answer->qid), 'answers' => stripslashes($answer->answers), 'votes' => intval($answer->votes)); } // If View Results if(intval($_GET['showresults']) == 1) { $vote_text = '

Vote

'; } // If User Click Vote if(isset($_POST['vote'])) { if(isset($_POST['poll-'.$polls_questions[0]['id']])) { $voted = true; } } // Check User Cookie if(isset($_COOKIE["voted_".$polls_questions[0]['id']])) { $voted = true; } ?>

Current Poll

'; echo "\n".$polls_questions[0]['question']."\n"; foreach($polls_answers as $polls_answer) { if($polls_questions[0]['id'] == $polls_answer['qid']) { if(intval($polls_questions[0]['total_votes']) > 0) { $percentage = round((($polls_answer['votes']/$polls_questions[0]['total_votes'])*100)); $imagebar = $percentage; } else { $percentage = 0; $imagebar = 1; } echo "\n".$polls_answer['answers']."
\"$percentage%\n"; echo "$percentage%\n\n"; } unset($polls_answer); } echo "\nTotal Votes: ".$polls_questions[0]['total_votes']."$vote_text\n"; echo '
'; } else { echo '
'; echo ""; echo ''; echo "\n\n\n\n
".$polls_questions[0]['question']."
"; foreach($polls_answers as $polls_answer) { if($polls_questions[0]['id'] == $polls_answer['qid']) { echo " ".$polls_answer['answers']."
\n"; unset($polls_answer); } } echo '

View Results
'; } // Delete The First Poll From The Array unset($polls_questions[0]); ?>

Polls Archive

'; echo "\n".$polls_question['question']."\n"; foreach($polls_answers as $polls_answer) { if($polls_question['id'] == $polls_answer['qid']) { if(intval($polls_question['total_votes']) > 0) { $percentage = round((($polls_answer['votes']/$polls_question['total_votes'])*100)); $imagebar = $percentage; } else { $imagebar = 1; } echo "\n".$polls_answer['answers']."
\"$percentage%\n"; echo "$percentage%\n\n"; // Delete Away From Array unset($polls_answer['answers']); } } echo "\nTotal Votes: ".$polls_question['total_votes']."\n"; echo '

'; $i++; } ?>