initial commit
This commit is contained in:
24
power.php
Normal file
24
power.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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);
|
||||
?>
|
||||
Reference in New Issue
Block a user