Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user = "root";
- $pass = "";
- $host = "localhost";
- $dbname = "near_deal";
- $store_id = $_REQUEST['store_id'];
- // Create connection
- $conn = new mysqli($host, $user, $pass, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //get data
- $sql = "SELECT *,DATEDIFF(end_date,CURDATE()) sisahari FROM product as p INNER JOIN deal as 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'],
- 'sisahari_discount' => $row['sisahari'],
- '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
- ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement