23 lines
527 B
PHP
23 lines
527 B
PHP
<?php
|
|
require_once __DIR__ . '/common.php';
|
|
|
|
$dbconn = getDBConnection();
|
|
|
|
// Performing SQL query
|
|
$query = "SELECT lat,lon,outagen FROM power WHERE active = true and cwa = 'RLX'";
|
|
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
|
|
|
|
// Printing results in HTML
|
|
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
|
|
$array[] = $line;
|
|
}
|
|
echo json_encode($array);
|
|
|
|
// Free resultset
|
|
pg_free_result($result);
|
|
|
|
// Close database connection when needed
|
|
if (isset($dbconn)) {
|
|
pg_close($dbconn);
|
|
}
|
|
?>
|