Location: PHPKode > projects > Backend code/CMS for blizzle.com > v1.x/blizlets/poll.php
<?

global $pollvote, $pollcookie, $pollidh, $cookiesEnabled,$here;


if (($pollvote) && ($pollcookie != $pollidh)) {

if ($cookiesEnabled == "true") {

setcookie("pollcookie",$pollidh,time()+2592000,"/");
$query = "UPDATE polls SET pollvalue$pollvote = pollvalue$pollvote + 1 WHERE pollid = $pollidh;";
$result = mysql_query ($query, $link) or die (mysql_error());
$response = "Thanks for your vote!<p>";

} else {

$response = "Sorry, you must enable cookies to vote.<p>";

}

}





$bHtml = "";

$query = "SELECT * FROM polls ORDER BY polldate DESC LIMIT 1;";

$result = mysql_query ($query, $link) or die (mysql_error());

list($pollid, $itemid, $pollquestion, $polldate, $pollanswer1, $pollanswer2, $pollanswer3, $pollanswer4, $pollanswer5, $pollanswer6, $pollanswer7, $pollanswer8, $pollvalue1, $pollvalue2, $pollvalue3, $pollvalue4, $pollvalue5, $pollvalue6, $pollvalue7, $pollvalue8) = mysql_fetch_row($result);



if (!$cookiesEnabled) {
$response = "You must have cookies enabled to vote.<p>";
}
if ($pollcookie == $pollid) {
$response = "Thanks for your vote!<p>";
}

$total = $pollvalue1 + $pollvalue2 + $pollvalue3 + $pollvalue4 + $pollvalue5 + $pollvalue6 + $pollvalue7 + $pollvalue8;



if ($total == 0) {

$total = 1;

}






if (($pollvote) || ($pollcookie == $pollid)) {



$bHtml = $bHtml."$response$pollquestion<br>\n";

if ($itemid) {
$bHtml = $bHtml."<center>[<a href=\"index.php?uid=$itemid\">discuss this</a>]</center><br>\n";
}

if ($pollanswer1) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer1<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue1/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue1/$total)*100,0)."% ($pollvalue1/$total)<br>\n";

}

if ($pollanswer2) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer2<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue2/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue2/$total)*100,0)."% ($pollvalue2/$total)<br>\n";

}

if ($pollanswer3) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer3<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue3/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue3/$total)*100,0)."% ($pollvalue3/$total)<br>\n";

}

if ($pollanswer4) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer4<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue4/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue4/$total)*100,0)."% ($pollvalue4/$total)<br>\n";

}

if ($pollanswer5) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer5<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue5/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue5/$total)*100,0)."% ($pollvalue5/$total)<br>\n";

}

if ($pollanswer6) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer6<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue6/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue6/$total)*100,0)."% ($pollvalue6/$total)<br>\n";

}

if ($pollanswer7) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer7<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue7/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue7/$total)*100,0)."% ($pollvalue7/$total)<br>\n";

}

if ($pollanswer8) {

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png>$pollanswer8<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue8/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue8/$total)*100,0)."% ($pollvalue8/$total)<br>\n";

}



} else {



$bHtml = $bHtml."$response$pollquestion<form method=post action=$here><input type=hidden name=pollidh value=$pollid>\n";
if ($itemid) {
$bHtml = $bHtml."<center>[<a href=\"index.php?uid=$itemid\">discuss this</a>]</center><br>\n";
}
if ($pollanswer1) {

$bHtml = $bHtml."<input type=radio name=pollvote value=1> $pollanswer1<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue1/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue1/$total)*100,0)."% ($pollvalue1/$total)<br>\n";

}

if ($pollanswer2) {

$bHtml = $bHtml."<input type=radio name=pollvote value=2> $pollanswer2<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue2/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue2/$total)*100,0)."% ($pollvalue2/$total)<br>\n";

}

if ($pollanswer3) {

$bHtml = $bHtml."<input type=radio name=pollvote value=3> $pollanswer3<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue3/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue3/$total)*100,0)."% ($pollvalue3/$total)<br>\n";

}

if ($pollanswer4) {

$bHtml = $bHtml."<input type=radio name=pollvote value=4> $pollanswer4<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue4/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue4/$total)*100,0)."% ($pollvalue4/$total)<br>\n";

}

if ($pollanswer5) {

$bHtml = $bHtml."<input type=radio name=pollvote value=5> $pollanswer5<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue5/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue5/$total)*100,0)."% ($pollvalue5/$total)<br>\n";

}

if ($pollanswer6) {

$bHtml = $bHtml."<input type=radio name=pollvote value=6> $pollanswer6<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue6/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue6/$total)*100,0)."% ($pollvalue6/$total)<br>\n";

}

if ($pollanswer7) {

$bHtml = $bHtml."<input type=radio name=pollvote value=7> $pollanswer7<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue7/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue7/$total)*100,0)."% ($pollvalue7/$total)<br>\n";

}

if ($pollanswer8) {

$bHtml = $bHtml."<input type=radio name=pollvote value=8> $pollanswer8<br>\n";

$bHtml = $bHtml."<img width=20 height=10 src=/commonimages/spacer.png><img height=10 width=".round(($pollvalue8/$total)*100,0)." src=/commonimages/hbar.png><br><img width=30 height=10 src=/commonimages/spacer.png>".round(($pollvalue8/$total)*100,0)."% ($pollvalue8/$total)><br>\n";

}

$bHtml = $bHtml."<center><input type=submit name=submit value=submit></form></center>";



}



createBlizlet('Current Poll',$bHtml);

?>
Return current item: Backend code/CMS for blizzle.com