-
Notifications
You must be signed in to change notification settings - Fork 0
/
secResSearch.php
145 lines (134 loc) · 3.75 KB
/
secResSearch.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
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
<title>Secretary's Search Reservation Page</title>
</head>
<style>
.topnav{
padding:0px;
background-color: grey;
text-align: center;
border-radius: 10px;
}
.dropbtn {
background-color: grey;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
position: absolute;
display: none;
background-color: grey;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: black;}
.dropdown:hover .dropdown-content {display: block;}
.dropbtn:hover {
background-color: white;
color: grey;
}
</style>
<body>
<?php
session_start();
if(!isset($_SESSION["username"]))
header("Location: login.html");
?>
<div class="header">
<h1>MyBusApp</h1>
</div>
<div class="topnav">
<div class="dropdown">
<button class="dropbtn">Reservations</button>
<div class="dropdown-content">
<a href="secretaryNewRes.php">New Reservation</a>
<a href="secretaryResSearch.php">Reservation Search</a>
<a href="secretaryCancelRes.php">Cancel Reservation</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Customers</button>
<div class="dropdown-content">
<a href="secretaryNewCust.php">New Customer Registration</a>
<a href="secretaryCustSearch.php">Customer Search</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Destinations</button>
<div class="dropdown-content">
<a href="secretaryNewDest.php">New Destination Registration</a>
<a href="secretaryDesSearch.php">Destination Search</a>
<a href="secretaryViewDest.php">View Destinations</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Trip</button>
<div class="dropdown-content">
<a href="secretaryNewTrip.php">Create new Trip</a>
<a href="secretarySearchTrips.php">Search Trips</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Drivers</button>
<div class="dropdown-content">
<a href="secretaryNewDriver.php">Add new Driver</a>
<a href="secretaryDriverSearch.php">Driver Search</a>
</div>
</div>
</div>
<div>
<p>Search Results</p>
<table><?php
include "config.php";
$conn -> select_db("heroku_ed39a20fb4d6fd8");
$tripID = $_POST["tripID"];
$customerID = $_POST["customerID"];
if (!empty($customerID) && !empty($tripID)){
$query = "SELECT * FROM reservation WHERE Trip_tripID = '$tripID' AND Customer_customerID = '$customerID'";
$result = mysqli_query($conn, $query);
} elseif (!empty($customerID)){
$query = "SELECT * FROM reservation WHERE Customer_customerID = '$customerID'";
$result = mysqli_query($conn, $query);
} elseif(!empty($tripID)){
$query = "SELECT * FROM reservation WHERE Trip_tripID = '$tripID'";
$result = mysqli_query($conn, $query);
}else {
echo "Please try one of two , or both.";
}
$all_data = array();
while ($data = mysqli_fetch_field($result)) {
echo '<td>' . $data->name . '</td>'; //get field name for header
array_push($all_data, $data->name); //save those to array
}
echo '</tr>'; //end tr tag
//showing all data
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
foreach ($all_data as $item) {
echo '<td>' . $row[$item] . '</td>'; //get items using data value
}
echo '</tr>';
}
echo "</table>";
?></table>
</div>
<div>
<a href="logout.php">Log out</a>
</div>
</body>
</html>