-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgetgyms.php
More file actions
30 lines (22 loc) · 692 Bytes
/
getgyms.php
File metadata and controls
30 lines (22 loc) · 692 Bytes
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
<?php
//Use same config as bot
require_once("config.php");
// Establish mysql connection.
$dbh = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4", DB_USER, DB_PASSWORD, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$dbh->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
$rows = array();
try {
$sql = "SELECT * FROM gyms WHERE show_gym = 1";
$result = $dbh->query($sql);
while($gym = $result->fetch(PDO::FETCH_ASSOC)) {
$rows[] = $gym;
}
}
catch (PDOException $exception) {
error_log($exception->getMessage());
$dbh = null;
exit;
}
print json_encode($rows);
$dbh = null;
?>