3 $page_name = 'Poll Maker';
4 require ('config.php');
5 $level_restriction = ADMIN
;
6 require ('top.inc.php');
8 if (isset ($_POST['submit']))
12 for ($i = 1; $i <= 8; $i++
)
14 $query1 .= '`option'.$i.'`, ';
15 $query2 .= '\''.mysql_real_escape_string ($_POST['option'.$i]).'\', ';
17 $pollname = mysql_real_escape_string ($_POST['pollname']);
19 mysql_query ('INSERT INTO `poll` (`pollname`, '.$query1.' `polldate`) VALUES (\''.$pollname.'\', '.$query2.' UNIX_TIMESTAMP())');
22 echo '<div class="c3">Start New Poll</div>
23 <form action="'.urlpath(2).'" method="post">
24 <div class='.colour().'>Poll name: <input type="text" name="pollname" maxlength="50"/></div>';
26 for ($optnum = 1; $optnum <= 8; $optnum++
)
27 echo '<div class='.colour().'>Option '.$optnum.': <input type="text" name="option'.$optnum.'" maxlength="100"/></div>'."\n";
29 echo '<div class="c3"><input type="submit" name="submit" value="Create new poll"/></div>
33 $pollinfo = mysql_fetch_row (mysql_query ('SELECT * FROM `poll` ORDER BY `pollid` DESC LIMIT 1'));
36 $sum = array_sum (array_slice ($pollinfo, 10, 8));
37 echo '<div class="c3">Current poll results for: '.$pollinfo[1].': '.$sum.' votes</div>
39 <tr><th>Option</th><th style="width:66%">Votes</th></tr>
41 for ($optnum2 = 0; $optnum2 < 8; $optnum2++
)
43 $widthpc = ($sum && $pollinfo[($optnum2+
10)]) ?
round ($pollinfo[($optnum2+
10)] / $sum * 100, 1) : 0;
44 if ($pollinfo[($optnum2+
2)])
45 echo '<tr class='.colour().'><td>'.$pollinfo[($optnum2+
2)].'</td><td><span class="alert" style="width:'.$widthpc.'%;display:block">'.$pollinfo[($optnum2+
10)].'</span></td></tr>