News

{$cutoff} and newstime <= unix_timestamp() order by newstime desc, newsid"); echo mysql_error(); $newsnumber = mysql_num_rows($result); if ($newsnumber > 0) { echo "
    "; while ($newsinfo = mysql_fetch_array($result)) { echo "
  • "; if ($currentday == date("F j", $newsinfo['newstime'])) echo "

    " . date('g:i a',$newsinfo['newstime']) . "

    "; else { $currentday = date("F j", $newsinfo['newstime']); if ($first == 0) { $first = 1; echo "

    {$currentday} - " . date('g:i a T',$newsinfo['newstime']) . "

    "; } else echo "

    {$currentday} - " . date('g:i a',$newsinfo['newstime']) . "

    "; } echo "

    " . unfixupdisplay($newsinfo['newspublic']) . "

    "; if ($newsinfo['newsupdate'] != "") echo "

    Update: " . unfixupdisplay($newsinfo['newsupdate']) . "

    "; echo "
  • "; } echo "
"; echo "All news"; } else echo "

No news has been added in the past seven days.

View past news.

"; echo "
"; // End div news // Grab data and display the newest polls. $month = date("n",time()); $day = date("j",time()); $cutoff = mktime(23,59,59,$month, ($day - $newslength), $electionyear); // One of the below two lines should be remarked. The first is for normal usage. The second is used for local testing only and displays all polls on the front page. $result = polls($connection,"left join states on (stateid = pollstateid) left join companies on (pcompid = pollpcompid) left join flips on (pollid = flippollid) join polldata on (pollid = pdpollid) left join candidates on (pdcandid = candid) where polltime > {$cutoff} and pollhidden = 'N' order by polltime desc, pollid desc"); // $result = polls($connection,"left join states on (stateid = pollstateid) left join companies on (pcompid = pollpcompid) left join flips on (pollid = flippollid) join polldata on (pollid = pdpollid) left join candidates on (pdcandid = candid) where pollhidden = 'N' order by polltime desc, pollid desc"); $numberofresults = mysql_num_rows($result); echo mysql_error(); echo "
"; echo "

The latest polls

"; if ($numberofresults > 0) { // Convert the $result to an array. $i = 0; // Just in case it had a value somehow. 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, unknown). // We can merge many of the arrays together. $pollinfo2[$j][$pollinfo[$i]['pdtype']][$pollinfo[$i]['candpartyabbr']] = $pollinfo[$i]['pdpercent']; // 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 ""; for ($k = 1; $k <= $j; $k++) { // Determine what color we want to use. if ($colorclass == "") $colorclass = " class=\"stripe\""; else $colorclass = ""; // Figure out how we wanna list the date. if (date("F j", $pollinfo2[$k]['polltime']) != $olddate) { $olddate = date("F j", $pollinfo2[$k]['polltime']); if ($k == 1) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $colorclass = ""; } else { echo ""; $colorclass = ""; } } echo pollnews($pollinfo2[$k], $connection, $dest, $colorclass); } echo "
DateStatePollsterSampleClintonTrumpMoE
Added " . date("F j", $pollinfo2[$k]['polltime']) . "
Added " . date("F j", $pollinfo2[$k]['polltime']) . "
"; echo "All polls"; } else echo "

There are no new polls to list.

View the archive of polls.

"; echo "
"; // #poll-col echo "
"; // #news-wrap echo "
"; // end content div include("includes/footer.php"); ?>