-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.php
52 lines (44 loc) · 1.32 KB
/
results.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<?php
$st = htmlspecialchars($_GET["st"]);
$party = htmlspecialchars($_GET["party"]);
include "connection.php";
$stateTrm = trim($st, " \t\n\r");
$partyTrm = trim($party, " \t\n\r");
$sql = "SELECT * FROM electionresults NATURAL JOIN candidates WHERE party = '" . $partyTrm . "' AND st = '" . $stateTrm . "'";
$result = $con->query($sql);
$row = $result->fetch_assoc();
?>
<head>
<title>ElectionResults</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<style>
#ontainer {
position: absolute;
}
</style>
<body>
<?php include "css/navbar.php"?>
<div id="container">
<div id="state-container">
<?php
if ($result->num_rows > 0) {
echo
"<h4>State: " . $row["st"] .
"</h4>\n<p>Canadate: " . $row["name"] .
"</p>\n<p>Party: " . $row["party"] .
"</p>\nPopular Vote: " . $row["popVotes"] * 100 .
"%</p>\nElectoral Votes: " . $row["electVotes"];
} else {
echo $result->num_rows ." results";
}
?>
</div>
</div>
<div id="states">
<img src="images/votes-college-state.jpg" alt="votes-college-state">
</div>
</body>
</html>