Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. //HTML
  2. <div class="bs-example">
  3. <input type="text" name="city" id="city" class="city tt-query" autocomplete="off" spellcheck="false" placeholder="Type your Query">
  4. <input type="text" name="typeahead" class="typeahead tt-query" autocomplete="off" spellcheck="false" placeholder="Type your Query">
  5. </div>
  6.  
  7. //JS
  8. $(document).ready(function(){
  9. var var1 = $('#city').val();
  10. $('input.typeahead').typeahead({
  11. name: 'typeahead',
  12. remote:'search.php?key=%QUERY&key2=var1',
  13. limit : 10
  14. });
  15. });
  16.  
  17. //search.php
  18. <?php
  19. $key=$_GET['key'];
  20. $key2=$_GET['key2'];
  21. $array = array();
  22. $con=mysql_connect("localhost","root","");
  23. $db=mysql_select_db("newbach",$con);
  24. $query=mysql_query("select * from bk_area where city_id = '$key2' && area_name LIKE '%{$key}%'");
  25. while($row=mysql_fetch_assoc($query))
  26. {
  27. $array[] = $row['area_name'];
  28. }
  29. echo json_encode($array);
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement