Advertisement
Guest User

Untitled

a guest
Feb 13th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <?php
  2. $dbHost = 'localhost';
  3. $dbUsername = 'root';
  4. $dbPassword = '';
  5. $dbName = 'linknadotest';
  6. //connect with the database
  7. $db = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);
  8. //get search term
  9. $searchTerm = $_GET['term'];
  10. //get matched data from skills table
  11. $query = $db->query("SELECT * FROM community_links WHERE title LIKE '%".$searchTerm."%' ORDER BY title ASC LIMIT 5");
  12. while ($row = $query->fetch_assoc()) {
  13. $data[] = $row['title'];
  14. }
  15. //return json data
  16. echo json_encode($data);
  17. ?>
  18.  
  19. <!doctype html>
  20. <html lang="en">
  21. <head>
  22. <meta charset="utf-8">
  23. <title>Autocomplete textbox using jQuery, PHP and MySQL by CodexWorld</title>
  24. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  25. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  26. <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  27. <script>
  28. $(function() {
  29. $( "#title" ).autocomplete({
  30. source: 'search.php'
  31. });
  32. });
  33. </script>
  34. </head>
  35. <body>
  36.  
  37. <div class="ui-widget">
  38. <label for="title">Skills: </label>
  39. <input id="title">
  40. </div>
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement