Guest User

Untitled

a guest
Jan 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <?php
  2. //echo "ddjjdjd";die;
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $db ="rentozy_db";
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password,$db);
  10.  
  11. // Check connection
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15. echo "Connected successfully";
  16. //require_once ('db_connection.php');
  17.  
  18. $q=$_REQUEST["q"];
  19. //$q=$_REQUEST["term"];
  20. //$searchTerm = $_GET['term'];
  21.  
  22. $sql="SELECT `pg_address` FROM `tbl_master_property` WHERE pg_address LIKE '%$q%'";
  23. $result = mysql_query($sql);
  24.  
  25. $json=array();
  26.  
  27. while($row = mysql_fetch_array($result)) {
  28. array_push($json, $row['pg_address']);
  29. }
  30. echo json_encode($json);
  31. ?>
  32.  
  33. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  34. <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
  35. <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
  36. <script type="text/javascript">
  37. $(function() {
  38. $( "#location" ).autocomplete({
  39. source: function( request, response ) {
  40. $.ajax({
  41. url: "gethint.php",
  42. dataType: "jsonp",
  43. data: {
  44. q: request.term
  45. },
  46. success: function(data) {
  47. response(data);
  48. }
  49. });
  50. },
  51. });
  52. });
  53. </script>
  54.  
  55. <input type="text" id="location" placeholder="Search by location" name="location" list="locations" class="searchlocation" />
Add Comment
Please, Sign In to add comment