jquery - Google map and PHP, SQL -
i want link json result google map. have imei_number
in database password of user. once user enter right password(imei_number
in database), system select longitude , latitude of imei_number
selected , later link google map's longitude , latitude. html code is:
<form method="post" action="loginserver.php"> <label> username: </label> <input type = "text" maxlength = "20" name = "user" id= "user" /> <br /> <label> password: </label> <input type = "password" maxlength= "20" name="pass" id= "pass" /> <br /> <input type ="button" onclick="" value="clear" /> <input type = "submit" value = "login"id= "btn"/> </p> </form>
the google map page is
<script type = "text/javascript"> function loadmap(){ var mapedit = { zoom: 8, center: new google.maps.latlng($.getjson('connect.php', function(data) { $.each(data, function(key, val) { $("ul").append(val.latitude); }); }); , $.getjson('connect.php', function(data) { $.each(data, function(key, val) { $("ul").append(val.longitude); }); }); ), maptypeid: google.maps.maptypeid.roadmap } var map = new google.maps.map(document.getelementbyid("map"), mapedit); var marker = new google.maps.marker({ position: new google.maps.latlng( $.getjson('connect.php', function(data) { $.each(data, function(key, val) { $("ul").append(val.latitude); }); }); , $.getjson('connect.php', function(data) { $.each(data, function(key, val) { $("ul").append(val.longitude); }); }); ), map: map, }); marker.addlistener('click', function(){ infowindow.open(map, marker); }); } </script> </head> <body onload = "loadmap()"> <div id="map" style="width: 400px; height: 500px;"></div>
the connect.php is
<?php include 'linker.php'; $sql = "select * android_data $pass = 'imei_number'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_array($result)) { $data[] = $row; $row["longitude"]); $row["longitude"]. " - latitude: " . $row["latitude"]. "<br>"; } } else { echo "0 results"; } echo json_encode($data); mysqli_close($conn); ?>
the linker.php is
<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "project_gps"; $user = $_post['user']; $pass = $_post['pass']; $user = stripcslashes($user); $pass = stripcslashes($pass); $conn = mysqli_connect($servername, $username, $password, $dbname); $user = mysqli_real_escape_string($conn, $user); $pass = mysqli_real_escape_string($conn, $pass); if($conn){ echo "connected"; } if (!$conn) { die("connection failed: " . mysqli_connect_error()); } ?>
but not working. please, can do?
Comments
Post a Comment