[Firebug-cvs] firebug/web/gmaps db_render_xml.php,1.10,1.11
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2005-06-20 17:50:33
|
Update of /cvsroot/firebug/firebug/web/gmaps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20530 Modified Files: db_render_xml.php Log Message: php script now uses a view for getting locations and conditions in the same query. Index: db_render_xml.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/gmaps/db_render_xml.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** db_render_xml.php 14 Jun 2005 20:24:57 -0000 1.10 --- db_render_xml.php 20 Jun 2005 17:50:16 -0000 1.11 *************** *** 72,76 **** */ $dbname = "rfs_demo_06_09_2005"; ! $tblname = "gga_l"; global $ids, $images, $icons, $global_id; --- 72,77 ---- */ $dbname = "rfs_demo_06_09_2005"; ! $tblname = "location_conditions"; //"gga_l"; ! global $ids, $images, $icons, $global_id; *************** *** 81,85 **** } ! $statement = "SELECT a.attname FROM pg_attribute a,pg_class c where c.relname ='$tblname' and a.attrelid = c.oid and a.attnum > 0"; $stat = @pg_exec($dbh,$statement); if(!stat) { --- 82,86 ---- } ! $statement = "SELECT a.attname FROM pg_attribute a,pg_class c where c.relname = '$tblname' and a.attrelid = c.oid and a.attnum > 0"; $stat = @pg_exec($dbh,$statement); if(!stat) { *************** *** 94,97 **** --- 95,99 ---- } + $statement = "SELECT * FROM $tblname"; $stat = @pg_exec($dbh,$statement); *************** *** 99,102 **** --- 101,105 ---- die("Cannot select from table\n"); } + /*** *************** *** 113,117 **** foreach ($row as $key => $value) { ! // print "$key"; //$value\n"; switch($labels[$key]) { case "latitudedegree": --- 116,120 ---- foreach ($row as $key => $value) { ! //print ("$labels[$key]: $value, "); switch($labels[$key]) { case "latitudedegree": *************** *** 127,130 **** --- 130,142 ---- $longmin=$value; break; + case "temperature": + $temp=$value; + break; + case "humidity": + $humidity=$value; + break; + case "pressure": + $pressure=$value; + break; case "nodeid": $nodeid=$value; *************** *** 144,175 **** $title = "Firebug sensor $nodeid"; ! ! $query = "SELECT temperature,humidity,pressure FROM xbow_weather_l where nodeid = $nodeid"; ! $result = @pg_query($dbh,$query); ! if(!result) { ! die("Cannot select from table\n"); ! } ! ! $wrow = pg_fetch_array($result, NULL, PGSQL_ASSOC) or perr("db_render_xml", "Cannot retrieve data"); ! $temp = $wrow["temperature"]; ! $humidity = $wrow["humidity"]; ! $pressure = $wrow["pressure"]; ! ! $address = "<line>Firebug sensor $nodeid</line><line>Temp: $temp C</line><line>Rel. Hum: $humidity%</line><line>Press: $pressure mBar</line>"; emit_gps_location($id,$lat,$long,$image,$icon,$title,$address); $global_id = $i; - - - - - } - pg_close($dbh); } - - print("<?xml version=\"1.0\"?>\n"); print("<page>\n"); --- 156,167 ---- $title = "Firebug sensor $nodeid"; ! $address = "<line>Firebug sensor $nodeid</line><line>Temp: $temp C, Rel. Hum: $humidity%, Press: $pressure mBar</line><line>Lat: $lat, Long: $long</line>"; emit_gps_location($id,$lat,$long,$image,$icon,$title,$address); $global_id = $i; } pg_close($dbh); } print("<?xml version=\"1.0\"?>\n"); print("<page>\n"); *************** *** 181,186 **** print("<overlay panelStyle=\"sidepanel.xsl\">\n\n\n"); - - // An ugly function, can be refactored later. print_from_database(); --- 173,176 ---- *************** *** 193,201 **** $image = "images/sitar.jpg"; - //print($icon); emit_gps_location($id,$lat,$long,$icon,$image,'Nick\'s office',$address); - //$address = '<line>Dave and Karthik</line>'; - print("</overlay>\n"); print("</page>\n"); --- 183,188 ---- |