"; stderr( _("Delete poll"), sprintf( _("Do you really want to delete a poll? Click %s here %s if you are sure."), $link, '') ); } do_mysql_query("DELETE FROM pollanswers WHERE pollid = $pollid") or sqlerr(); do_mysql_query("DELETE FROM polls WHERE id = $pollid") or sqlerr(); if ($returnto == "main") header("Location: ".$GLOBALS['DEFAULTBASEURL']); else header("Location: polls.php?deleted=1"); die; } $rows = do_mysql_query("SELECT COUNT(*) FROM polls") or sqlerr(); $row = mysql_fetch_row($rows); $pollcount = $row[0]; if ($pollcount == 0) stderr( _("Sorry..."), _("There are no polls!") ); $polls = do_mysql_query("SELECT *,UNIX_TIMESTAMP(added) as utadded FROM polls ORDER BY id DESC LIMIT 1," . ($pollcount - 1 )) or sqlerr(); stdhead( _("Previous polls")); print("

". _('Previous polls')."

"); while ($poll = mysql_fetch_assoc($polls)) { $o = array($poll["option0"], $poll["option1"], $poll["option2"], $poll["option3"], $poll["option4"], $poll["option5"], $poll["option6"], $poll["option7"], $poll["option8"], $poll["option9"], $poll["option10"], $poll["option11"], $poll["option12"], $poll["option13"], $poll["option14"], $poll["option15"], $poll["option16"], $poll["option17"], $poll["option18"], $poll["option19"]); print("

\n"); print("

"); $added = $poll['added']. " GMT (".get_elapsed_time($poll['utadded'])." ago)"; echo $added; if (get_user_class() >= UC_ADMINISTRATOR) { print(" - [Edit]\n"); print(" - [Delete]\n"); } print(""); print("

\n"); print("
\n"); print("

" . $poll["question"] . "

"); $pollanswers = do_mysql_query("SELECT selection FROM pollanswers WHERE pollid=" . $poll["id"] . " AND selection < 20") or sqlerr(); $tvotes = mysql_num_rows($pollanswers); $vs = array(); // count for each option ([0]..[19]) $os = array(); // votes and options: array(array(123, "Option 1"), array(45, "Option 2")) // Count votes while ($pollanswer = mysql_fetch_row($pollanswers)) $vs[$pollanswer[0]] += 1; reset($o); for ($i = 0; $i < count($o); ++$i) if ($o[$i]) $os[$i] = array($vs[$i], $o[$i]); // now os is an array like this: if ($poll["sort"] == "yes") usort($os, srt); print("\n"); $i = 0; while ($a = $os[$i]) { if ($tvotes > 0) $p = round($a[0] / $tvotes * 100); else $p = 0; if ($i % 2) $c = ""; else $c = " bgcolor=#ECE9D8"; print("\n"); ++$i; } print("
" . $a[1] . "  " . " $p%
\n"); $tvotes = number_format($tvotes); print("

Votes: $tvotes

\n"); print("
\n"); print("

\n"); } stdfoot(); ?>