title: Displaying from database using javascript
body: <p>So i am using this code example to get a cascaded drop down menu. But i want to add names of people residing in a city. How do i add that when a city is selected?
  link to demo- <a href="http://www.infotuts.com/demo/cascaded-drop-down-jquery-php/" rel="nofollow">http://www.infotuts.com/demo/cascaded-drop-down-jquery-php/</a></p>
  
  <p>Entire code-
  INDEX.PHP</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  include("connection.php");
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Cascaded dropdown with jQuery Ajax and PHP | Easyscript4u.com&lt;/title&gt;
  &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="container"&gt;
    &lt;div id="body"&gt;
      &lt;div class="mhead"&gt;&lt;h2&gt;Cascaded dropdown with jQuery Ajax and PHP | Easyscript4u.com&lt;/h2&gt;&lt;/div&gt;
   &lt;div id="dropdowns"&gt;
         &lt;div id="center" class="cascade"&gt;
            &lt;?php
    $sql = "SELECT * FROM tbl_country ORDER BY country_name";
    $query = mysqli_query($con, $sql);
    ?&gt;
              &lt;label&gt;Country:
              &lt;select name="country" id = "drop1"&gt;
                &lt;option value=""&gt;Please Select&lt;/option&gt;
                &lt;?php while ($rs = mysqli_fetch_array($query, MYSQLI_ASSOC )) { ?&gt;
                &lt;option value="&lt;?php echo $rs["id"]; ?&gt;"&gt;&lt;?php echo $rs["country_name"]; ?&gt;&lt;/option&gt;
                &lt;?php } ?&gt;
              &lt;/select&gt;
              &lt;/label&gt;
            &lt;/div&gt;
  
          &lt;div class="cascade" id="state"&gt;&lt;/div&gt; 
  
            &lt;div id="city" class="cascade"&gt;&lt;/div&gt; 
          &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;script src="jquery-1.9.0.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
  $("select#drop1").change(function(){
  
   var country_id =  $("select#drop1 option:selected").attr('value'); 
  // alert(country_id); 
   $("#state").html( "" );
   $("#city").html( "" );
   if (country_id.length &gt; 0 ) { 
    
    $.ajax({
     type: "POST",
     url: "fetch_state.php",
     data: "country_id="+country_id,
     cache: false,
     beforeSend: function () { 
      $('#state').html('&lt;img src="loader.gif" alt="" width="24" height="24"&gt;');
     },
     success: function(html) {    
      $("#state").html( html );
     }
    });
   } 
  });
  });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>STATE.PHP</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  include("connection.php");
  $country_id = trim(mysql_escape_string($_POST["country_id"]));
  
  $sql = "SELECT * FROM tbl_state WHERE country_id = ".$country_id ." ORDER BY state_name";
  $count = mysqli_num_rows( mysqli_query($con, $sql) );
  if ($count &gt; 0 ) {
  $query = mysqli_query($con, $sql);
  ?&gt;
  &lt;label&gt;State: 
  &lt;select name="state" id="drop2"&gt;
   &lt;option value=""&gt;Please Select&lt;/option&gt;
   &lt;?php while ($rs = mysqli_fetch_array($query, MYSQLI_ASSOC)) { ?&gt;
   &lt;option value="&lt;?php echo $rs["id"]; ?&gt;"&gt;&lt;?php echo $rs["state_name"]; ?&gt;&lt;/option&gt;
   &lt;?php } ?&gt;
  &lt;/select&gt;
  &lt;/label&gt;
  &lt;?php 
   }
  
  ?&gt;
  
  &lt;script src="jquery-1.9.0.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
  
  
  $("select#drop2").change(function(){
  
   var state_id = $("select#drop2 option:selected").attr('value');
     // alert(state_id);
   if (state_id.length &gt; 0 ) { 
    $.ajax({
     type: "POST",
     url: "fetch_city.php",
     data: "state_id="+state_id,
     cache: false,
     beforeSend: function () { 
      $('#city').html('&lt;img src="loader.gif" alt="" width="24" height="24"&gt;');
     },
     success: function(html) {    
      $("#city").html( html );
     }
    });
   } else {
    $("#city").html( "" );
   }
  });
  
  });
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>CITY.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  include("connection.php");
  $state_id = trim(mysql_escape_string($_POST["state_id"]));
   
  $sql = "SELECT * FROM tbl_city WHERE state_id = ".$state_id ." ORDER BY city_name";
  $count = mysqli_num_rows( mysqli_query($con, $sql) );
  if ($count &gt; 0 ) {
  $query = mysqli_query($con, $sql);
  ?&gt;
  &lt;label&gt;City: 
  &lt;select name="city" name="box"&gt;
   &lt;option value=""&gt;Please Select&lt;/option&gt;
   &lt;?php while ($rs = mysqli_fetch_array($query, MYSQLI_ASSOC)) { ?&gt;
   &lt;option value="&lt;?php echo $rs["id"]; ?&gt;"&gt;&lt;?php echo $rs["city_name"]; ?&gt;&lt;/option&gt;
   &lt;?php } ?&gt;
  &lt;/select&gt;
  &lt;/label&gt;
  &lt;?php 
   }
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I think there should be a javascript running which calls on the names of people in a particular city in the database. But i have no idea how to go about. Because i am a total newbie.
  Thank you</p>