-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdice.php
133 lines (108 loc) · 4.59 KB
/
dice.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Analytical Data - Dice </title>
<link rel="stylesheet" href="./css/style_reset.css" type="text/css">
<link rel="stylesheet" href="./css/help.css" type="text/css">
<link rel="stylesheet" href="./css/openflights.css" type="text/css">
<style type="text/css"></style>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<div id="mainContainer">
<div id="sideBarContentWrapper">
<div id="contentContainer">
<div id="nonmap">
<h1>Airlines Reservation System</h1>
<a href="Home.php">
Home</a> | <a href="view.php">
View Reservation</a> |<a href="Airport.php">
Airport</a> | <a href="Airline.php">
Airline</a> | <a href="Route.php">
Route</a> | <a href="Analytical.php">
Analytical Operations</a>
<a name="airport"></a>
<h2>Analytical Operation - Dice</h2>
<?php
function constructTable($data)
{
// We're going to construct an HTML table.
echo '<table style="width:50%">';
// Construct the HTML table row by row.
$doHeader = true;
foreach ($data as $row) {
// The header row before the first data row.
if ($doHeader) {
print " <tr>\n";
foreach ($row as $name => $value) {
print " <th>$name</th>\n";
}
print " </tr>\n";
$doHeader = false;
}
// Data row.
print " <tr>\n";
foreach ($row as $name => $value) {
print " <td>$value</td>\n";
}
print " </tr>\n";
}
print " </table>\n";
}
$id = filter_input(INPUT_GET, "id");
try {
print "<h3>Dice Operation</h3>\n";
print "<h1>Before Dice</h1>\n";
// Connect to the database.
$con = new PDO("mysql:host=localhost;dbname=projectinclude",
"root", "root");
$con->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
$query = "Select employee.Name, calender.Quarter, sum(sales_fact_table.DollarsSold) as Revenue_Generated FROM calender, sales_fact_table, employee where calender.calenderKey = sales_fact_table.CalenderKey and sales_fact_table.EmployeeKey = employee.EmployeeKey group by calender.Quarter";
$query2 = "Select employee.Name, calender.Quarter, sum(sales_fact_table.DollarsSold) as Revenue_Generated FROM calender, sales_fact_table, employee where calender.calenderKey = sales_fact_table.CalenderKey and sales_fact_table.EmployeeKey = employee.EmployeeKey and (employee.Name = 'brucewayne' or employee.Name = 'derek') and (calender.Quarter ='Q3' or calender.Quarter='Q4') group by calender.Quarter";
//echo "<h4>Query : $query</h4><br>";
$ps = $con->prepare($query);
// Fetch the matching row.
$ps->execute(array(':id' => $id));
$data = $ps->fetchAll(PDO::FETCH_ASSOC);
// $data is an array.
if (count($data) > 0) {
constructTable($data);
echo "<br>";
}
else {
print "<h3>(No match.)</h3>\n";
}
print "<h1>After Dice</h1>\n";
//echo "<h4>Query : $query</h4><br>";
$ps1 = $con->prepare($query2);
// Fetch the matching row.
$ps1->execute(array(':id' => $id));
$data1 = $ps1->fetchAll(PDO::FETCH_ASSOC);
// $data is an array.
if (count($data1) > 0) {
constructTable($data1);
}
else {
print "<h3>(No match.)</h3>\n";
}
}
catch(PDOException $ex) {
echo 'ERROR: '.$ex->getMessage();
}
catch(Exception $ex) {
echo 'ERROR: '.$ex->getMessage();
}
?>
<br><button onclick="location.href='Analytical.php'">Go Back</button>
</div>
</div>
</div>
</div>
</body>
</html>