Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. $key=$_GET['key'];
  2.  
  3. $search_results_array = array();
  4.  
  5.  
  6. $sql = "SELECT * FROM `Product_Data` WHERE `Product_Name` LIKE '%{$key}%' OR `Product_Tags` LIKE '%{$key}%' ORDER BY `Product_Sequence` ASC";
  7.  
  8. $q = $db->query($sql);
  9. if (PEAR::isError($q)) {
  10. showError ($q);
  11. exit;
  12. }
  13.  
  14. $numRows = $q->numRows();
  15.  
  16. while ($row = $q->fetchRow()) {
  17.  
  18. $product_name = $row['Product_Name'];
  19. $product_id = $row['Product_ID'];
  20. $search_results_array[] = "<a href='/index.php?page=purchase&product_id=$product_id' class='livesearch_link'>$product_name</a>";
  21.  
  22. }
  23.  
  24. print json_encode($search_results_array);
  25.  
  26. <div class=".col-md-6">
  27. <div class="panel panel-default">
  28. <div class="bs-example">
  29. <input type="text" name="typeahead" class="typeahead tt-query" autocomplete="off" spellcheck="false" placeholder="Search">
  30. </div>
  31.  
  32. <script>
  33. $(document).ready(function(){
  34. $('input.typeahead').typeahead({
  35. name: 'typeahead',
  36. remote: '/manage/process_ajax_search.php?key=%QUERY',
  37. limit : 10,
  38. });
  39.  
  40.  
  41. });
  42.  
  43. $(document).on('click','.tt-suggestion .livesearch_link',function(e){
  44.  
  45. e.preventDefault();
  46.  
  47. var href = $(this).attr('href');
  48. window.location.replace(href);
  49.  
  50. return false;
  51.  
  52. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement