php Poll
hello everyone
Anyone can please Provide me some code for Poll, I already working on the actual physical Poll code,But i want easier way to call variables for all the options in place of $option1, $option2 etc.
Code
/*
$con = mysql_connect("host,"username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("SELECT * FROM polls WHERE poll_id = '$currentpoll'") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$option1 = $row[option1];
$option2 = $row[option2];
$option3 = $row[option3];
$op1total = $row[op1total];
$op2total = $row[op2total];
$op3total = $row[op3total];
*/
$option1 = Yes;
$option2 = No;
$option3 = Other;
$op1total = 5;
$op2total = 6;
$op3total = 2;
$total = $op1total + $op2total + $op3total;
$percent1 = $op1total / $total;
$percent2 = $op2total / $total;
$percent3 = $op3total / $total;
// }
echo 'Results';
echo '<br><br>';
echo "<table border=0><tr><td>" . $option1 . "</td><td> <img src=poll.gif height=20 width=" . $percent1 * 300 . "</img></td></tr>";
echo "<tr><td>" . $option2 . " </td><td><img src=poll.gif height=20 width=" . $percent2 * 300 . "</img></td></tr>";
echo "<tr><td>" . $option3 . " </td><td><img src=poll.gif height=20 width=" . $percent3 * 300 . "</img></td></tr></table>";
Thanks in advance
|