Skip to content

Instantly share code, notes, and snippets.

@Poshan Poshan/query.php
Created Jul 3, 2015

Embed
What would you like to do?
<html>
<style type="text/css">
.TFtable{
width:100%;
border-collapse:collapse;
}
.TFtable td{
padding:10px; border:#4e95f4 2px solid;
}
/* provide some minimal visual accomodation for IE8 and below */
.TFtable tr{
background: #b8d1f3;
}
/* Define the background color for all the ODD background rows */
.TFtable tr:nth-child(odd){
background: #b8d1f3;
}
/* Define the background color for all the EVEN background rows */
.TFtable tr:nth-child(even){
background: #dae5f4;
}
#map{
height: 80%;
width: 100%;
}
</style>
<link rel="stylesheet" href="css/leaflet.css">
<!--<script src = "js/displayQueryResult.js"></script>-->
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/leaflet.js"></script>
<script src = "js/leaflet.ajax.min.js"></script>
<script src = "js/zoomHome.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>
<script src="leaflet-plugins-1.3.0/layer/tile/Google.js"></script>
<script src="js/config.js"></script>
<script>
$(document).ready(function () {
//console.log('inside the init');
map = L.map(config["mapDOMId"],{zoomControl:false}).setView(config["mapOptions"]["initialCenter"], config["mapOptions"]["zoomLevelMin"]);
var mapbox = L.tileLayer(config["districtTiles"]);
mapbox.addTo(map);
var mapboxvdc = L.tileLayer(config["vdcTiles"]);
var ggl = new L.Google();
var rokka = new L.GeoJSON.AJAX(null,{
onEachFeature: function(feature, layer){
//create popup here
// console.log('rokka');
// debugger;
var content = '<table border = "1" style ="width:100%"><h4><tr><td>Mineral</td><td>Zone</td><td>District</td><td>Location</td><td>Area(sq. km)</td><td>Toposheet</td></tr></h4>';
content += '<tr><td>' + feature.properties.mineral + '</td>';
content += '<td>' + feature.properties.zone + '</td>';
content += '<td>' + feature.properties.district + '</td>';
content += '<td>' + feature.properties.location + '</td>';
content += '<td>' + feature.properties.area + '</td>';
content += '<td>' + feature.properties.toposheet + '</td></tr></table>';
layer.bindPopup(L.popup({
autopan:true,
maxWidth: 500
}).setContent(content));
//!@#@$%^&*^%$#@!$%^&*()^%$#@$(&*$#@!)
//add to storeAllPolygons
//also push the name of the mine to show which mine exists in a drawn area
var _southWest = {
"southWest": layer.getBounds()._southWest
};
var _northEast = {
"northEast": layer.getBounds()._northEast
};
var poly = [_southWest ,_northEast];
// storeAllPolygons.push(layer.getBounds());
// console.log(storeAllPolygons);
},
style: config["styles"]["rokkaKshetra"]["polygon"]
});
$.getJSON("togeojson.php",
function (data){
// console.log(data);
rokka.addData(data);
}).complete(function (){
rokka.addTo(map);
// console.log('rokkaKshetra loaded');
// checkIfInside(storeAllPolygons, "allPolygons");
});
var opening71 = new L.GeoJSON.AJAX(null,{
onEachFeature: function(feature, layer){
//create popup here
// debugger
var content = '<table border = "1" style ="width:100%"><h4><tr><td>Owner</td><td>Licence No.</td><td>Mineral</td><td>Zone</td><td>District</td><td>Location</td><td>Area(sq. km)</td><td>Toposheet</td></tr></h4>';
content += '<tr><td>' + feature.properties.owner + '</td>';
content += '<td>' + feature.properties.licenceno + '</td>';
content += '<td>' + feature.properties.mineral+ '</td>';
content += '<td>' + feature.properties.zone + '</td>';
content += '<td>' + feature.properties.district + '</td>';
content += '<td>' + feature.properties.location + '</td>';
content += '<td>' + feature.properties.area + '</td>';
content += '<td>' + feature.properties.toposheet + '</td></tr></table>';
layer.bindPopup(L.popup({
autopan:true,
keepInView:true,
maxWidth: 500
}).setContent(content));
//!@#@$%^&*^%$#@!$%^&*()^%$#@$(&*$#@!)
// debugger;
//add to storeAllPolygons
//also push the name of the mine to show which mine exists in a drawn area
var _southWest = {
"southWest": layer.getBounds()._southWest
};
var _northEast = {
"northEast": layer.getBounds()._northEast
};
// pushed the bounds instead of individual coordinates to use the contains function
// storeAllPolygons.push(layer.getBounds());
// console.log(storeAllPolygons);
},
style: config["styles"]["rokkaKshetra"]["polygon"]
});
$.getJSON("togeojsonopening.php", function (data){
opening71.addData(data);
}).complete(function (){
// opening71.addTo(map);
// console.log('opening71 loaded');
// checkIfInside(storeAllPolygons, "allPolygons");
});
var prospecting70 = new L.GeoJSON.AJAX(null,{
onEachFeature: function(feature, layer){
//create popup here
// debugger
var content = '<table border = "1" style ="width:100%"><h4><tr><td>Owner</td><td>Licence No.</td><td>Mineral</td><td>From (Date) </td><td>To (Date)</td><td>Zone</td><td>District</td><td>Location</td><td>Area(sq. km)</td><td>Toposheet</td></tr></h4>';
content += '<tr><td>' + feature.properties.owner + '</td>';
content += '<td>' + feature.properties.licenceno + '</td>';
content += '<td>' + feature.properties.mineral+ '</td>';
content += '<td>' + feature.properties.startdate+ '</td>';
content += '<td>' + feature.properties.enddate+ '</td>';
content += '<td>' + feature.properties.zone + '</td>';
content += '<td>' + feature.properties.district + '</td>';
content += '<td>' + feature.properties.location + '</td>';
content += '<td>' + feature.properties.area + '</td>';
content += '<td>' + feature.properties.toposheet + '</td></tr></table>';
layer.bindPopup(L.popup({
autopan:true,
keepInView:true,
maxWidth: 700
}).setContent(content));
//!@#@$%^&*^%$#@!$%^&*()^%$#@$(&*$#@!)
// debugger;
//add to storeAllPolygons
//also push the name of the mine to show which mine exists in a drawn area
var _southWest = {
"southWest": layer.getBounds()._southWest
};
var _northEast = {
"northEast": layer.getBounds()._northEast
};
var poly = [_southWest ,_northEast];
// storeAllPolygons.push(layer.getBounds());
// console.log(storeAllPolygons);
},
style: config["styles"]["rokkaKshetra"]["polygon"]
});
$.getJSON("togeojsonprospecting.php", function (data){
prospecting70.addData(data);
}).complete(function (){
// console.log('prospecting70 loaded');
// checkIfInside(storeAllPolygons, "allPolygons");
});
// prospecting70.addTo(map);
var prospecting_renew2071 = new L.GeoJSON.AJAX(null,{
onEachFeature: function(feature, layer){
//create popup here
// debugger
var html = '<table border="1" style="width:100%">';
html += '<tr><td>Owner Name</td></tr><tr><td>';
html += feature.properties.owner + '</td>';
html += '</tr>';
html += '</table>'
layer.bindPopup(L.popup({
closeOnClick: true,
closeButton: true,
keepInView: true,
autoPan: true,
}).setContent(html));
//!@#@$%^&*^%$#@!$%^&*()^%$#@$(&*$#@!)
// debugger;
//add to storeAllPolygons
//also push the name of the mine to show which mine exists in a drawn area
var _southWest = {
"southWest": layer.getBounds()._southWest
};
var _northEast = {
"northEast": layer.getBounds()._northEast
};
var poly = [_southWest ,_northEast];
// storeAllPolygons.push(layer.getBounds());
// console.log(storeAllPolygons);
},
style: config["styles"]["rokkaKshetra"]["polygon"]
});
$.getJSON("togeojson.php", function (data){
prospecting_renew2071.addData(data);
}).complete(function (){
// prospecting_renew2071.
// console.log('prospecting_renew2071 loaded');
// checkIfInside(storeAllPolygons, "allPolygons");
});
var baseLayers = {
"Districts": mapbox
};
var overlays = {
"Google": ggl,
"opening 71": opening71,
"prospecting70": prospecting70,
"prospecting_renew2071": prospecting_renew2071,
"VDC":mapboxvdc,
"Rokka": rokka
//"Transportation":trans,
//"Rivers":hydro
};
//addition of attribution
var attribution = config["attribution"];
map.attributionControl.setPrefix('');
L.control.attribution({
position: 'bottomright',
}).addAttribution(attribution).setPrefix('<a href= "http://www.leafletjs.com">leaflet</a>').addTo(map);
//addition of overlays and set the collapsed false
L.control.layers(baseLayers,overlays,{collapsed:false}).addTo(map);
// add the new control to the map
var zoomHome = new L.Control.zoomHome();
zoomHome.addTo(map);
// var queryResult = new L.Control.displayQueryResult();
// queryResult.addTo(map);
//easy way of doing so
// $("div.leaflet-control-zoom").append("<a class='new-control-zoom-to-extent' href=# title='Zoom to extent'><div id = 'zoom'><img src = 'img/MapFullExtent.png'></div></a>");
// $("a.new-control-zoom-to-extent").click(function(){
// set the map view
// document.activeElement.blur();
// });
});
</script>
<body>
<div id = "map"></div>
<div id = "closeMapDiv">
<button id = "closeMap">Close Map</button>
</div>
<script>
$("#closeMap").click(function(){
$("#map").hide();
$("#closeMap").hide();
});
$("#map").hide();
$("#closeMap").hide();
function showOnMap(a,b){
$("#map").show("slow");
$("#closeMap").show();
// var loc = L.latLng(b,a);
// var z = 7;
// map.setView(loc, z);
}
</script>
</body>
</html>
<?php
include "conf.php";
$input=$_POST['district'];
if($_POST['event'] == '1') {
$query = "SELECT * FROM opeaning WHERE (district='$input')";
$result = mysqli_query($connect, $query);
$row = mysqli_fetch_row($result);
if ($result->num_rows > 0) {
echo '<table class="TFtable" table-striped table border: "1" solid black; >';
echo"<TR><TD width='40' border: 1px solid black;><h3>S.N <h3></TD><TD width='40'><h3>Owner<h3></TD><TD width='50'><h3>Mineral<h3></TD><TD><h3>Licence_No <h3></TD><TD width='40'><h3>Zone<h3></TD><TD width='40'><h3>District<h3></TD><TD width='50'><h3>Location<h3></TD><TD><h3>Topo Sheet <h3></TD><TD Width='80' border=5px><h3>Total Area<h3></TD></TR>";
while($row = $result->fetch_assoc()) {
$x = $row["x"];
$xx = $row["xx"];
$y = $row["y"];
$yy = $row["yy"];
//create centroid
// now using only x and y
echo "<tr><td width = '40' border: 1px solid black;>";
echo $row["sn"];
echo "</td><td width = '40' border: 1px solid black;>";
// echo '<a href ="showonmap()">'.$row["owner"].'</a>';
echo "<a id = \"Mine Site\" href = \"javascript:showOnMap(" . $x . "," . $y . ");\">" . $row["owner"] . "</a>\n";
echo "</td><td width = '40' border: 1px solid black;>";
echo $row["mineral"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["licenceno"];
echo "</td><td width = '40'border: 1px solid black;>";
// echo $row["zone"];
echo '<a href ="showonmap()">'.$row["zone"].'</a>';
// echo "<a id = \"Mine Site\" href = \"javascript:showOnMap(" . $x . "," . $y . ");\">" . $row["zone"] . "</a>\n";
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["district"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["location"];
echo "</td><td width = '80'border: 1px solid black;>";
echo $row["toposheet"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["area"];
echo "</TD></tr>";
}
echo "</table>";
// output data of each row
// while($row = $result->fetch_assoc()) {
// echo "Licence Number: " . $row["licenceno"]. " - Name: " . $row["owner"]. "- Geometry: " . $row["SHAPE"]. " -Mineral " . $row["mineral"]. "<br>";
} else {
echo "0 results";
}
}
elseif($_POST['event'] == '2') {
$query = "SELECT * FROM prospecting WHERE (district='$input')";
$result = mysqli_query($connect, $query);
$row = mysqli_fetch_row($result);
if ($result->num_rows > 0) {
echo '<table class="TFtable table-striped table-border: 1px solid black; table-hover">';
echo"<TR><TD width='40' border: 1px solid black;><h3>S.N <h3></TD><TD width='40'><h3>Owner<h3></TD><TD width='50'><h3>Mineral<h3></TD><TD><h3>Licence-No <h3></TD><TD Width='80' border=5px><h3>Start Date<h3></TD><TD width='40'><h3>End Date<h3></TD><TD width='40'><h3>Zone<h3></TD><TD width='40'><h3>District<h3></TD><TD width='50'><h3>Location<h3></TD><TD><h3>Topo Sheet <h3></TD><TD Width='80' border=5px><h3>Area (SQ KM)<h3></TD></TR>";
while($row = $result->fetch_assoc()) {
echo "<tr><td width = '40' border: 1px solid black;>";
echo $row["sn"];
echo "</td><td width = '40' border: 1px solid black;>";
echo $row["owner"];
echo "</td><td width = '40' border: 1px solid black;>";
echo $row["mineral"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["licenceno"];
echo "</td><td width = '90'border: 1px solid black;>";
echo $row["startdate"];
echo "</td><td width = '80'border: 1px solid black;>";
echo $row["enddate"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["zone"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["district"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["location"];
echo "</td><td width = '80'border: 1px solid black;>";
echo $row["toposheet"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["area"];
echo "</TD></tr>";
}
echo "</table>";
// output data of each row
// while($row = $result->fetch_assoc()) {
// echo "Licence Number: " . $row["licenceno"]. " - Name: " . $row["owner"]. "- Geometry: " . $row["SHAPE"]. " -Mineral " . $row["mineral"]. "<br>";
} else {
echo "0 results";
}
}
elseif($_POST['event'] == '3') {
$query = "SELECT * FROM rokka WHERE (district='$input')";
$result = mysqli_query($connect, $query);
$row = mysqli_fetch_row($result);
if ($result->num_rows > 0) {
echo '<table class="TFtable table-striped table-border: 1px solid black; table-hover">';
echo"<TR><TD width='40' border: 1px solid black;><h3>Zone<h3></TD><TD width='40'><h3>District<h3></TD><TD width='50'><h3>Location<h3></TD><TD><h3>Mineral<h3></TD><TD Width='80' border=5px><h3>Area<h3></TD><TD width='40'><h3>TopoSheet<h3></TD><TD width='40'><h3>Remarks<h3></TD></TR>";
while($row = $result->fetch_assoc()) {
$x = $row["x"];
$xx = $row["xx"];
$y = $row["y"];
$yy = $row["yy"];
echo "<tr><td width = '40' border: 1px solid black;>";
// echo $row["zone"];
echo "<a id = \"mineSite\" href = \"javascript:showOnMap(" . $x . "," . $y . ");\">" . $row["zone"] . "</a>\n";
echo "</td><td width = '40' border: 1px solid black;>";
echo $row["district"];
echo "</td><td width = '40' border: 1px solid black;>";
echo $row["location"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["mineral"];
echo "</td><td width = '80'border: 1px solid black;>";
echo $row["area"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["toposheet"];
echo "</td><td width = '40'border: 1px solid black;>";
echo $row["remarks"];
echo "</TD></tr>";
}
echo "</table>";
// output data of each row
// while($row = $result->fetch_assoc()) {
// echo "Licence Number: " . $row["licenceno"]. " - Name: " . $row["owner"]. "- Geometry: " . $row["SHAPE"]. " -Mineral " . $row["mineral"]. "<br>";
} else {
echo "0 results";
}
}
else {
// query to get all records
$query = "SELECT * FROM mineral";
}
// $select = "SELECT * FROM opeaning Where mineral='Coal'";
// echo $select;
// $result = mysqli_query($connect, $query);
// $row = mysqli_fetch_row($result);
// $total=mysqli_num_rows($result);
// echo $total;
// if ($result->num_rows > 0) {
// echo '<table class="table table-striped table-bordered table-hover">';
// echo"<TR><TD>Licenc No</TD><TD>Owner:</TD><TD>Mineral</TD></TR>";
// while($row = $result->fetch_assoc()) {
// echo "<tr><td>";
// echo $row["licenceno"];
// echo "</td><td>";
// echo $row["owner"];
// echo "</td><td>";
// echo $row["mineral"];
// echo "</TD></tr>";
// }
// echo "</table>";
// // output data of each row
// // while($row = $result->fetch_assoc()) {
// // echo "Licence Number: " . $row["licenceno"]. " - Name: " . $row["owner"]. "- Geometry: " . $row["SHAPE"]. " -Mineral " . $row["mineral"]. "<br>";
// else {
// echo "0 results";
// }
$connect->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.