Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to pass location from jquery to php
    primarykey
    data
    text
    <p>This retrieves the map of the location:</p> <pre><code> &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/ 1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery.cookie.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function success(position) { var s = document.querySelector('#status'); if (s.className == 'success') { return; } s.innerHTML = "Found you!"; s.className = 'Success'; var mapcanvas = document.createElement('div'); mapcanvas.id = 'mapcanvas'; mapcanvas.style.height = '100%'; mapcanvas.style.width = '100%'; document.querySelector('#map').appendChild(mapcanvas); var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var myOptions = { zoom: 15, center: latlng, mapTypeControl: false, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); var marker = new google.maps.Marker({ position: latlng, map: map, title:"You are here!" }); $.cookie("MyLat", position.coords.latitude); // Storing latitude value $.cookie("MyLon", position.coords.longitude); // Storing longitude value } function error(msg) { var s = document.querySelector('#status'); s.innerHTML = typeof msg == 'string' ? msg : "failed"; s.className = 'Fail'; } if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(success, error); } else { error('Not supported'); //HTML Support } //Jquery Code $(document).ready(function() { $("#check").click(function() { var lat = $.cookie("MyLat"); var lon = $.cookie("MyLon"); alert('Latitued: '+lat); alert('Longitude: '+lon); var url="http://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+lon+"&amp;sensor=false"; alert('Google Map API: '+url); //Get Json Request Here }); }); &lt;/script&gt; //HTML Code &lt;input type='button' id='check' value='Check-out'/&gt; &lt;div id="status"&gt;Loading.............&lt;/div&gt; &lt;div id="map"&gt;&lt;/div&gt; </code></pre> <p>I want to get only city and street address using GPS in jQuery and pass that city location to the PHP below, assigning the city address in php variable $city = //from jquery.</p> <p>And pass in $sql statement.</p> <pre><code>(i.e "select e.id, e.firstName, e.lastName, e.title, e.picture, count(r.id) reportCount " . "from employee e left join employee r on r.managerId = e.id " . "group by e.id order by e.lastName, e.firstName where e.city=$city";) &lt;div data-role="content"&gt; &lt;ul data-role="listview" data-filter="true"&gt; &lt;?php include 'config.php'; $sql = "select e.id, e.firstName, e.lastName, e.title, e.picture, count(r.id) reportCount " . "from employee e left join employee r on r.managerId = e.id " . "group by e.id order by e.lastName, e.firstName"; try { $dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass); $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbh-&gt;query($sql); while ($emp = $stmt-&gt;fetch(PDO::FETCH_OBJ)) { echo "&lt;li&gt;&lt;a href='employeedetails.php?id=$emp-&gt;id'&gt;" . "&lt;img src='pics/$emp-&gt;picture'/&gt;" . "&lt;h4&gt;$emp-&gt;firstName $emp-&gt;lastName&lt;/h4&gt;" . "&lt;p&gt;$emp-&gt;title&lt;/p&gt;" . "&lt;span class='ui-li-count'&gt;$emp-&gt;reportCount&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;"; } $dbh = null; } catch(PDOException $e) { echo $e-&gt;getMessage(); } ?&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Help me in getting this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload