<% $cookiename = "CPLC51polls"; $pollsvoted = $CPLC51polls; function sqldate($d) { list($year,$month,$day,$hour,$minute,$second) = split("([^0-9])", $d ); return date("F j, Y",mktime($hour,$minute,$second,$month,$day,$year)); } function sqltime($d) { list($year,$month,$day,$hour,$minute,$second) = split("([^0-9])", $d ); return date("g:ia T, D, M j, Y",mktime($hour,$minute,$second,$month,$day,$year)); } %> Poll Question
51 Division Community / Police Liaison Committee

What do you think???

<% $caller = strlen($REMOTE_HOST) ? $REMOTE_HOST : $REMOTE_ADDR; require('/www/.phpinc/pg_connect_cplc.inc'); $sql = "SELECT max(whattime) FROM pollanswers;"; $rs = pg_exec($cnx, $sql); $row = pg_fetch_row($rs, 0); %>

What are the latest results of all polls?
Latest activity: <%=sqltime($row[0]) %>

<% $sql = "SELECT * FROM pollquestions WHERE " . "(startdate IS NULL OR startdate < now()) AND " . "(enddate IS NULL OR enddate > now()) ORDER BY qid DESC;"; $qcount = pg_numrows($rs_q = pg_exec($cnx, $sql)); if ($qcount == 0) { %>

Sorry, there are currently no questions open for voting. <% } else { echo "

Add your vote to "; if ($qcount == 1) echo "this informal, unscientific poll."; else echo "these informal, unscientific polls."; %>
Please only vote once for each question.

<% if ($qcount > 1) { echo "
\nWe are currently asking the following questions:\n
\n\n"; } %>
<% for ($r = 0; $r < $qcount; $r++) { $qrow = pg_fetch_array($rs_q, $r); $qid = $qrow["qid"] %> ">
Question <%=htmlspecialchars($qrow["qname"]) %>: <% if (($d = $qrow[("enddate")]) == NULL) echo "(no defined time limit)"; else echo "vote before ", sqldate($d), ""; %>

<%=htmlspecialchars($qrow["question"]) %>

<% $sql = "SELECT * FROM polloptions WHERE qid = " . $qid . ";"; $ocount = pg_numrows($rs_o = pg_exec($cnx, $sql)); for ($o = 0; $o < $ocount; $o++) { $orow = pg_fetch_array($rs_o, $o); $otext = $orow["option"]; if ($otext > "") echo "", htmlspecialchars($otext), "
\n"; } %>

<% if (empty($pollsvoted)) { $sql = "SELECT DISTINCT qid FROM pollanswers WHERE qid IN (" . "SELECT qid FROM pollquestions WHERE " . "(startdate IS NULL OR startdate < now()) AND " . "(enddate IS NULL OR enddate > now()))" . " AND address = '" . $caller . "';"; $votedbefore = $vcount = pg_numrows(pg_exec($cnx, $sql)); $morequestions = $qcount - $vcount - 1; } elseif (strpos(" " . $pollsvoted, "," . $qid . ",")) { $votedbefore = true; $sql = "SELECT qid FROM pollquestions WHERE " . "(startdate IS NULL OR startdate < now()) AND " . "(enddate IS NULL OR enddate > now())" . " AND qid IN (0" . $pollsvoted . "0);"; $vcount = pg_numrows($rs = pg_exec($cnx, $sql)); $morequestions = $qcount - $vcount -1; } else { $votedbefore = false; $morequestions = $qcount - 1; } if ($votedbefore) { %> Note: you appear to have voted on this question already!    <% } %>

  <% } } %>

You can comment more extensively in our discussion forum.

E-mail us a suggestion for another poll!

<% pg_close($cnx); %>