25 lines
670 B
PHP
25 lines
670 B
PHP
<?php
|
|
// Connecting, selecting database
|
|
$dbconn = pg_connect("host=localhost dbname=nws user=nws password=nws")
|
|
or die('Could not connect: ' . pg_last_error());
|
|
|
|
// Performing SQL query
|
|
//$query = "SELECT distinct on (camid) camid, filepath FROM camdb order by camid,dateutc desc";
|
|
$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);
|
|
|
|
// Closing connection
|
|
pg_close($dbconn);
|
|
?>
|