title: Google map and PHP, SQL
body: <p>I want to link my json result to the google map. I have a <code>imei_number</code> in the database which is the password of the user. Once the user enter the right password(<code>imei_number</code> in the database), the system will select the longitude and latitude of the <code>imei_number</code> selected and later link it to the google map's longitude and latitude.
  The HTML code is:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form method="post" action="loginServer.php"&gt;
      &lt;label&gt; Username: &lt;/label&gt; 
      &lt;input type = "text" maxlength = "20" name = "user" id= "user" /&gt;
      &lt;br /&gt;
      &lt;label&gt; Password: &lt;/label&gt;
      &lt;input type = "password" maxlength= "20" name="pass" id= "pass" /&gt;
      &lt;br /&gt;
      &lt;input type ="Button" onclick="" value="Clear" /&gt;
      &lt;input type = "Submit" value = "Login"id= "btn"/&gt;
  &lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The Google map page is</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script type = "text/javascript"&gt;
  
    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);
      });
  }
  
  &lt;/script&gt;
  
  &lt;/head&gt; 
  &lt;body onload = "LoadMap()"&gt;
  &lt;div id="map" style="width: 400px; height: 500px;"&gt;&lt;/div&gt; 
  </code></pre>
  
  <p>The connect.php is</p>
  
  <pre><code>&lt;?php
  
  include 'linker.php';
  
  $sql = "SELECT * FROM android_data WHERE $pass = 'imei_number'";
  $result = mysqli_query($conn, $sql);
  
  if (mysqli_num_rows($result) &gt; 0) {
      while($row = mysqli_fetch_array($result)) {
  
          $data[] = $row; 
          $row["longitude"]);
          $row["longitude"]. " - latitude: " . $row["latitude"]. "&lt;br&gt;";
      }
  } else {
      echo "0 results";
  }
  echo json_encode($data);
  mysqli_close($conn);
  ?&gt; 
  </code></pre>
  
  <p>The linker.php is</p>
  
  <pre><code>&lt;?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());
  }
  ?&gt;
  </code></pre>
  
  <p>But they are not all working. Please, what can I do?</p>