Guest User

Untitled

a guest
Dec 15th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. function lotSearch ($connect, $search) {
  2.  
  3. $sql = "SELECT lots.id, lots.title, categories.title AS cats_title, price, description, open_date, close_date, image_path, is_open FROM lots " .
  4. "JOIN categories ON lots.category_id = categories.id " .
  5. "WHERE is_open = 1 AND lots.title LIKE %?% OR description LIKE %?% ORDER BY open_date DESC";
  6.  
  7. $stmt = mysqli_prepare($connect, $sql);
  8.  
  9. mysqli_stmt_bind_param($stmt, "ss", $search, $search);
  10.  
  11. mysqli_stmt_execute($stmt);
  12.  
  13. mysqli_stmt_bind_result($stmt, $lots_id, $lots_title, $cats_title, $price, $description, $open_date, $close_date, $image_path, $is_open);
  14.  
  15. $lots_search = [];
  16.  
  17. while (mysqli_stmt_fetch($stmt)) {
  18.  
  19. $lots_search[] = [
  20.  
  21. 'id' => $lots_id,
  22. 'title' => $lots_title,
  23. 'cats_title' => $cats_title,
  24. 'price' => $price,
  25. 'description' => $description,
  26. 'open_date' => $open_date,
  27. 'close_date' => $close_date,
  28. 'image_path' => $image_path,
  29. 'is_open' => $is_open,
  30.  
  31. ];
  32.  
  33. };
  34.  
  35. return $lots_search;
  36.  
  37. };
Add Comment
Please, Sign In to add comment