-
Notifications
You must be signed in to change notification settings - Fork 0
/
institutions.php
184 lines (159 loc) · 6.25 KB
/
institutions.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
// define variables and set to empty values
include_once 'db_connection.php';
session_start();
$loggedIn = false;
if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == 1)
{
$loggedIn = true;
$userID = $_SESSION['id'];
}
//$id = $_GET["id"];
$sql = "SELECT `ID`, `Name`, `Email`, `Rating`, `Phone` FROM `Users` WHERE `isInstitution` = 1";
$result = $conn->query($sql);
$totalItems = mysqli_num_rows($result);
$itemsPerPage = 12;
$totalPages = ceil($totalItems / $itemsPerPage);
// Check that the page number is set.
if(!isset($_GET['page'])){
$_GET['page'] = 0;
}else{
// Convert the page number to an integer
$_GET['page'] = (int)$_GET['page'];
}
// If the page number is less than 1, make it 1.
if($_GET['page'] < 1){
$_GET['page'] = 1;
// Check that the page is below the last page
}else if($_GET['page'] > $totalPages){
$_GET['page'] = $totalPages;
}
$currentPage = (int)$_GET['page'];
$location = "";
$searched = "";
if(!empty($_SESSION["search"]))
$searched = $_SESSION["search"];
else
$_SESSION["search"] = "";
if(!empty($_SESSION["location"]))
$location = $_SESSION["location"];
else
$_SESSION["location"] = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if(isset($_POST["search"])){
$searched = test_input($_POST["search"]);
$_SESSION["search"] = $searched;
//echo "1";
}
elseif(isset($_POST["location"])){
$location = $_POST["location"];
$_SESSION["location"] = $location;
//echo "3";
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="institutions.css">
<script>
function autoSubmitCategory()
{
var categoryFormObject = document.forms['categoryForm'];
categoryFormObject.submit();
}
function autoSubmitLocation()
{
var locationFormObject = document.forms['locationForm'];
locationFormObject.submit();
}
</script>
</head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.7.0/css/all.css' integrity='sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ' crossorigin='anonymous'>
<body>
<div class="logo">
<b> Lost & Found </b>
</div>
<div class="topnav">
<a href="index.php" style="float:right"><i class="fa fa-fw fa-home"></i>Home</a>
<a href="account.php" style="float:right"><i class="fa fa-fw fa-user"></i>Account</a>
<a href="institutions.php" class="active" style="float:right"><i class="fa fa-fw fa-globe"></i>Search Places</a>
<a href="items.php" style="float:right"><i class="fa fa-fw fa-search"></i>Search Items</a>
<a href="found.php" style="float:right"><i class='fas fa-hand-holding-heart'></i>Found Something</a>
<form name="searchForm" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<input type="text" name="search" placeholder="Search.." value="<?php echo($_SESSION['search']); ?>">
<input type="submit"
style="position: absolute; left: -9999px; width: 1px; height: 1px;"
tabindex="-1" name="submitSearch" value="<?php echo $searched; ?>" />
</form>
</div>
<div class="row">
<div class="leftcolumn">
<div class="card2">
<form name="locationForm" id="locationForm" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<h1>Location</h1>
<label class="container">View All
<input type="radio" name="location" <?php if ($location == "") { ?>checked='checked' <?php } ?>value="" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Buildings
<input type="radio" name="location" <?php if ($location == "Building") { ?>checked='checked' <?php } ?>value="Building" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Museums
<input type="radio" name="location" <?php if ($location == "Museum") { ?>checked='checked' <?php } ?>value="Museum" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Cafes
<input type="radio" name="location" <?php if ($location == "Coffee") { ?>checked='checked' <?php } ?>value="Coffee" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Restaurants
<input type="radio" name="location" <?php if ($location == "Restaurant") { ?>checked='checked' <?php } ?>value="Restaurant" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Universities
<input type="radio" name="location" <?php if ($location == "University") { ?>checked='checked' <?php } ?>value="University" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Parks
<input type="radio" name="location" <?php if ($location == "Park") { ?>checked='checked' <?php } ?>value="Park" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Libraries
<input type="radio" name="location" <?php if ($location == "Library") { ?>checked='checked' <?php } ?>value="Library" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
<label class="container">Public Places
<input type="radio" name="location" <?php if ($location == "Place") { ?>checked='checked' <?php } ?>value="Place" onChange="autoSubmitLocation();">
<span class="checkmark"></span>
</label>
</form>
</div>
</div>
<div class="rightcolumn">
<?php include 'showInstitutions.php'; ?>
</div>
</div>
<div class="footer">
<div class="center">
<div class="pagination">
<?php include 'pagination.php'; ?>
</div>
</div>
</div>
<br>
<div class="center">
<a href="privacy.html" class="links"> Privacy Policy </a> --- <a href="terms.html" class="links"> Terms of use</a>
</div>
</body>
</html>