Guest User

Untitled

a guest
Dec 27th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2. $user="root";
  3. $pass="";
  4. $host="localhost";
  5. $dbnamne="neardeal";
  6.  
  7. $product_id = $_REQUEST['product_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. $sql = "SELECT p.*,s.name store_name, s.photo store_photo, d.*
  17. FROM store s INNER JOIN product p ON(s.id=p.store_id) LEFT JOIN deal d ON (p.id =d.product_id)
  18. WHERE p.id={$product_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. 'name' => $row ['name'],
  27. 'photo' => $row ['photo'],
  28. 'store_name' => $row['store_name'],
  29. 'store_photo' => $row['store_photo'],
  30. 'price' => $row ['price'],
  31. 'price_old' => $row['price'],
  32. 'description' => $row ['description'],
  33.  
  34. );
  35. }
  36. echo json_encode($deal);
Add Comment
Please, Sign In to add comment