Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. //fetch.php
  3. if(isset($_POST["query"])){
  4. $connect = mysqli_connect("private", "private", "private", "private");
  5. $request = mysqli_real_escape_string($connect, $_POST['query']);
  6. $query = "
  7. SELECT * FROM search_product
  8. WHERE produktnamn LIKE '%".$request."%'
  9. OR specifikationer LIKE '%".$request."%'
  10. ";
  11. $result = mysqli_query($connect, $query);
  12. $data = array();
  13. $html = '';
  14. $html .= '
  15. <table class="table table-bordered table-striped">
  16. <tr>
  17. <th>Name</th>
  18. <th>Specifications</th>
  19. </tr>
  20. ';
  21. }
  22. }if(mysqli_num_rows($result) == 0){
  23. $data = 'No Data Found';
  24. $html .= '
  25. <tr>
  26. <td colspan="3">No Results Found</td>
  27. </tr>
  28. ';
  29. }
  30. $html .= '</table>';
  31. if(isset($_POST['typehead_search']))
  32. {
  33.  echo $html;
  34. }
  35. else
  36. {
  37.  array_unique($data);
  38. echo json_encode($data);
  39. }
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement