Guest User

Untitled

a guest
Dec 27th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2. $user="root";
  3. $pass="";
  4. $host="localhost";
  5. $dbnamne="neardeal";
  6.  
  7. $store_id = $_REQUEST['store_id'];
  8.  
  9. //create connection
  10. $conn = new mysqli($host, $user, $pass, $dbnamne);
  11.  
  12. //check connection
  13. if($conn->connect_error){
  14. die("connection failed" .$com->connect_error);
  15. }
  16.  
  17. $sql = "SELECT * FROM product p INNER JOIN deal d ON(p.id=d.product_id)
  18. WHERE p.store_id={$store_id} ";
  19.  
  20. $result = $conn->query($sql);
  21. $deals = array();
  22.  
  23. while($row =$result->fetch_assoc()){
  24. $deal = array(
  25. 'id' => $row['id'],
  26. 'start_date' => $row['start_date'],
  27. 'end_date' => $row['end_date'],
  28. 'discount' => $row['discount'],
  29. 'product' => array(
  30. 'id' => $row['id'],
  31. 'store_id' => $row ['store_id'],
  32. 'name' => $row ['name'],
  33. 'price' => $row ['price'],
  34. 'description' => $row ['description'],
  35. 'photo' => $row ['photo'],
  36. )
  37. );
  38. $deals[]=$deal;
  39.  
  40. }
  41.  
  42. echo json_encode(array(
  43. 'success' => true,
  44. 'deal' => $deals
  45. ));
Add Comment
Please, Sign In to add comment