diff --git a/change.php b/change.php new file mode 100644 index 0000000..2d9cbbb --- /dev/null +++ b/change.php @@ -0,0 +1,29 @@ +query($r) === TRUE) { + //echo "New record created successfully"; +//} else { + //echo "Error: " . $sql . "" . $conn->er + + + $id = $_GET['i']; + $hub = $_GET['id']; + $stat=$_GET['stat']; + if($stat=='ON') + $query = "UPDATE sensor_list set status='OFF' WHERE Sensor_id='".$id."' and hub_id = '".$hub."'"; + else + $query = "UPDATE sensor_list set status='ON' WHERE Sensor_id='".$id."' and hub_id = '".$hub."'"; + + echo $query; + if ($conn->query($query) === TRUE) { + echo 'ok'; + + header("Location: sensor.php?id=".$hub); + } + + exit; // finish execution since we only need the "ok" or "err" answers from the server. + +?> \ No newline at end of file diff --git a/del.php b/del.php index 7e9eff5..d625a11 100644 --- a/del.php +++ b/del.php @@ -11,7 +11,7 @@ $id = $_GET['i']; $hub = $_GET['id']; - $query = "DELETE FROM sensor_list WHERE Sensor_name='".$id."'"; + $query = "DELETE FROM sensor_list WHERE Sensor_id='".$id."'"; echo $query; if ($conn->query($query) === TRUE) { echo 'ok'; diff --git a/handle.php b/handle.php index 86ed8fb..5316c7c 100644 --- a/handle.php +++ b/handle.php @@ -10,8 +10,8 @@ $stat = $_GET["status"]; $freq = $_GET["freq"]; -$sql = "INSERT INTO sensor_list (Sensor_name, Sensor_id, lon, lat, hub_id,status) -VALUES ('$sensor', '$fromat', '$desc', '$url ', '$hub', '$api')"; +$sql = "INSERT INTO sensor_list (Sensor_name, Sensor_id, lon, lat, hub_id,status, type) +VALUES ('$sensor', '$fromat', '$desc', '$url ', '$hub', '$api','$stat')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; diff --git a/markers.html b/markers.html index 8ef4087..24e35cb 100644 --- a/markers.html +++ b/markers.html @@ -24,28 +24,11 @@ $(document).ready(function(){ map = new GMaps({ el: '#map', - lat: 37.890998840332, - lng: -122.446998596191, + lat: 36, + lng: -122, zoom: 4 }); - map.addMarker({ - lat: 37.890998840332, - lng: -122.446998596191, - title: '', - details: { - database_id: 42, - author: 'HPNeo' - }, - click: function(e){ - if(console.log) - console.log(e); - alert('You clicked in this marker'); - }, - mouseover: function(e){ - if(console.log) - console.log(e); - } - }); + $.ajax({ url: 'un.php', //the script to call to get data data: "", //you can insert url argumnets here to pass to api.php @@ -57,10 +40,23 @@ $.each(data, function(k, v) { /// do stuff + map.addMarker({ lat: v.lat, lng: v.lon, - title: v.sensor + title: v.sensor, + se: v.hub, + click: function(e){ + if(console.log) + console.log(e); + var newURLString = "sensor.php" + + "?id=" + v.hub; + window.location.href = newURLString; + }, + mouseover: function(e){ + if(console.log) + console.log(e); + } }); }); diff --git a/sensor.php b/sensor.php index 61c4fa4..2b6ca9c 100644 --- a/sensor.php +++ b/sensor.php @@ -40,7 +40,7 @@ Sensor Name - Sensor ID + Sensor Type Status Manage @@ -66,11 +66,12 @@ $a = $conn->query($r); while( $row = mysqli_fetch_array($a) ){ - echo "" . $row['Sensor_name'] . "" . $row['Sensor_id'] . "" . $row['status'] . ""; - $i = $row['Sensor_name']; //$row['index'] the index here is a field name - echo ' '; - echo ' Delete  '; - echo ' Edit Status'; + echo "" . $row['Sensor_name'] . "" . $row['type'] . "" . $row['status'] . ""; + $i = $row['Sensor_id']; //$row['index'] the index here is a field name + $stat=$row['status']; + echo ' '; + echo ' Delete  '; + echo 'Change'; echo ''; echo ''; } @@ -105,9 +106,18 @@ Select Existing Sensor hub - + + Sensor Type + + Wind Speed + Wind Direction + Tidal Speed + Sensor Status - + + ON + OFF + Please Provide the Correct Information so that We can MAP your Sensor correctly. Submit @@ -133,7 +143,7 @@ New Status - + Submit diff --git a/un.php b/un.php index aa24e44..70adc7d 100644 --- a/un.php +++ b/un.php @@ -24,8 +24,9 @@ $lat = $row['lat']; $lon = $row['lon']; $name = $row['name']; + $id = $row['id']; - $rows[] = array("lat" => $lat, "lon" => $lon, "sensor" => $name ); + $rows[] = array("lat" => $lat, "lon" => $lon, "sensor" => $name, "hub" => $id ); # code... } header('Content-type:application/json');
Please Provide the Correct Information so that We can MAP your Sensor correctly.