Last active
August 29, 2015 14:04
-
-
Save mduleone/9149ef34c86df55edfc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db_params = new stdClass(); | |
$db_params->host = "localhost"; | |
$db_params->user = "Matt"; | |
$db_params->pass = ""; | |
$db_params->database = "parks"; | |
$db_params->query = "SELECT * FROM currentQueue ORDER BY arrive ASC"; | |
$db = mysqli_init(); | |
$conn = $db->real_connect($db_params->host, | |
$db_params->user, | |
$db_params->pass, | |
$db_params->database); | |
if (!$conn) { | |
die("Failed to connect to MySQL: " . $db->error); | |
} | |
$query = $db->query($db_params->query); | |
if(!$query) { | |
return; | |
} | |
$results = array(); | |
foreach ($query->fetch_all(MYSQLI_ASSOC) as $row) { | |
$rowArray = array(); | |
foreach ($row as $col => $value) { | |
$rowArray[$col] = $value; | |
} | |
$results[] = $rowArray; | |
} | |
echo json_encode ($results, JSON_PRETTY_PRINT) . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment