-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-variation.php
23 lines (17 loc) · 1.11 KB
/
get-variation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
include './conn/conn.php';
$variation_id = $_GET['variation_id'];
$query = mysqli_query($con, "SELECT * FROM variations WHERE id = $variation_id");
$variation = $query->fetch_assoc();
$product_id = $variation['product_id'];
$properties = [];
$image = mysqli_query($con,"SELECT * FROM property_values WHERE variation_id = $variation_id AND property_id IN (SELECT id FROM properties WHERE product_id = $product_id AND property_name='Image')")->fetch_assoc()['value'];
$price = mysqli_query($con,"SELECT * FROM property_values WHERE variation_id = $variation_id AND property_id IN (SELECT id FROM properties WHERE product_id = $product_id AND property_name='Price')")->fetch_assoc()['value'];
$get_properties = mysqli_query($con,"SELECT * FROM property_values WHERE variation_id = $variation_id AND property_id IN (SELECT id FROM properties WHERE product_id = $product_id AND property_name != 'Price' AND property_name != 'Image')");
while($row = $get_properties->fetch_assoc()){
array_push($properties, $row);
}
$data['image'] = $image;
$data['price'] = $price;
$data['properties'] = $properties;
echo json_encode($data);