2019 Elections Results by State

View Upcoming 2019 Elections


[insert_php]
$searchTerm=isset($_POST[‘searchTerm’])? trim($_POST[‘searchTerm’]) : “All States”;
echo “

    ” . $searchTerm . “

    * = New Mayor

“;
//connect to the database
$db=mysqli_connect(“127.0.0.1”, “uscm”, “QfqKmrOv2OmqgKUzKSV3”, “wp_uscm”) or die (‘I cannot connect to the database because: ‘ . mysql_error());
//-query the database table
$date = “2019”;
$sql=”SELECT * from ElectionResults LEFT JOIN Account ON ElectionResults.CityID = Account.External_ID__c WHERE LastElectionYears LIKE ‘$date%’ “;
if($searchTerm != “All States”) {
$sql .= “AND State__c = ‘” . $searchTerm. “‘ “;
}
$sql .= “Order by City”;
//-run the query against the mysql query function
$result=mysqli_query($db, $sql);
//-create while loop and loop through result set
while($row=mysqli_fetch_array($result)){
$CityID=$row[‘CityID’];
$City=$row[‘City’];
$State=$row[‘State’];
$StateName=$row[‘State__c’];
$FullName=$row[‘FullName’];
$ElectionDateNotes=$row[‘ElectionDateNotes’];
$ElectionDateNotes2=$row[‘ElectionDateNotes2’];
$Population=$row[‘Population__c’];
$Incumbent=$row[‘Incumbent’];
//-display the result of the array
if($Incumbent == “No”) {
$MayorDisplay = “*”;
} else {
$MayorDisplay = “”;
}
echo “

“;
}
[/insert_php]

Winner City, State Population Month Elected/Appointed

” . $MayorDisplay . “ ” . $ElectionDateNotes . “ ” . $City. “, ” . $State . “ ” . number_format($Population) . “ ” . $ElectionDateNotes2. “