Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user="root";
- $pass="";
- $host="localhost";
- $dbnamne="neardeal";
- $store_id = $_REQUEST['store_id'];
- //create connection
- $conn = new mysqli($host, $user, $pass, $dbnamne);
- //check connection
- if($conn->connect_error){
- die("connection failed" .$com->connect_error);
- }
- $sql = "SELECT * FROM product p INNER JOIN deal d ON(p.id=d.product_id)
- WHERE p.store_id={$store_id} ";
- $result = $conn->query($sql);
- $deals = array();
- while($row =$result->fetch_assoc()){
- $deal = array(
- 'id' => $row['id'],
- 'start_date' => $row['start_date'],
- 'end_date' => $row['end_date'],
- 'discount' => $row['discount'],
- 'product' => array(
- 'id' => $row['id'],
- 'store_id' => $row ['store_id'],
- 'name' => $row ['name'],
- 'price' => $row ['price'],
- 'description' => $row ['description'],
- 'photo' => $row ['photo'],
- )
- );
- $deals[]=$deal;
- }
- echo json_encode(array(
- 'success' => true,
- 'deal' => $deals
- ));
Add Comment
Please, Sign In to add comment