0) $stateinfo = mysql_fetch_array($result); else $warning = "The URL contains an invalid state ID."; $sort = "date"; } if (isset($_GET['pcomp'])) { $pcomptoloadphrase = "and pcompid = '" . strtoupper(fixup($_GET['pcomp'], '')) . "' "; $result = pollsters($connection,"where pcompid = '" . strtoupper(fixup($_GET['pcomp'], '')) . "'"); if (mysql_num_rows($result) > 0) $pollsterinfo = mysql_fetch_array($result); else $warning = "The URL contains an invalid pollster ID."; } if (isset($_GET['sort'])) { if ($_GET['sort'] == "date") $sort = "date"; } ?> In A Democracy
All polls"; else echo "

{$stateinfo['statename']} polls

"; if (($sort == "date") and ($statetoloadphrase == "")) echo "

Sort by state - date

"; elseif ($statetoloadphrase == "") echo "

Sort by state - date

"; else echo "

View all polls

"; if ($numberofresults > 0) { // Convert the $result to an array. $i = 0; // Just in case it had a value somehow. $j = 0; // Ditto while ($pollinfo[$i] = mysql_fetch_array($result)) $i++; // Merge various lines of the array. for ($i = 0; $i <$numberofresults; $i++) { // Advance $j if we're working on a new pollid. if ($lastpollid != $pollinfo[$i]['pollid']) { $j++; $lastpollid = $pollinfo[$i]['pollid']; // Start a new [$j] value by grabbing the $pollinfo[$i] array. $pollinfo2[$j] = $pollinfo[$i]; } // Which unfortunately is only the data for one candidate. within a single poll sample type (registered, likely, or unknown). // We can merge many of the arrays together. $pollinfo2[$j][$pollinfo[$i]['pdtype']][$pollinfo[$i]['candpartyabbr']] = $pollinfo[$i]['pdpercent']; $candidates[$pollinfo[$i]['candpartyabbr']] = $pollinfo[$i]['candlast']; // Grab both types of flip data and put it in a special area of the array. if (($pollinfo[$i]['flipfrom'] == "D") or ($pollinfo[$i]['flipfrom'] == "R")) { $pollinfo2[$j]['flip2']['from'] = $pollinfo[$i]['flipfrom']; $pollinfo2[$j]['flip2']['to'] = $pollinfo[$i]['flipto']; } if (($pollinfo[$i]['flipfrom'] == "SD") or ($pollinfo[$i]['flipfrom'] == "SR") or ($pollinfo[$i]['flipfrom'] == "LD") or ($pollinfo[$i]['flipfrom'] == "LR") or ($pollinfo[$i]['flipfrom'] == "T")) { $pollinfo2[$j]['flip']['from'] = $pollinfo[$i]['flipfrom']; $pollinfo2[$j]['flip']['to'] = $pollinfo[$i]['flipto']; } } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; foreach ($candidates as $key => $var) { if (($key != 'D') and ($key != 'R')) echo ""; else echo ""; } echo ""; echo ""; echo ""; echo ""; for ($k = 1; $k <= $j; $k++) { // Determine what color we want to use. if ($colorclass == "") $colorclass = " class=\"stripe\""; else $colorclass = ""; echo listpolls($pollinfo2[$k], $connection, $dest, $colorclass, $candidates, $sort); } echo "
StateDatePollsterClientSample *{$var} ({$key}){$var}Other **Undecided **MoE
"; echo "

Percentages in the above table may not add up to 100% due to rounding.

"; echo "

* For samples, L = likely voters, R = registered voters, and U = unknown or other voter type. Polls with a likely voter model typically show a 1-2 point swing toward Republican candidates over polls using a registered voter model. Each model has been more accurate at predicting the outcome depending on the election year. Generally speaking, the registered voter model becomes more accurate as turnout increases.

"; echo "

** These labels may be somewhat inaccurate depending on the wording of the poll. Generally speaking, the "other" column in the above chart consists of responses for "other" or "someone else". The "undecided" column contains responses for "undecided", "neither", "not sure", or "other/undecided". The chart above does not include percentages for "won't vote" or "declined to answer".

"; } else echo "

There are no polls to list.

"; ?>