added product & shop

This commit is contained in:
StockiP
2022-05-23 09:26:57 +02:00
parent 8b0044470e
commit dd12b3f6ee
17 changed files with 473 additions and 19 deletions

35
logic/getProductData.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
getData();
function getData()
{
require($_SERVER['DOCUMENT_ROOT'] . '/config/setupDBAccess.php');
$sql = "SELECT `product_id`, `name`, `price`, `description`, `stock`, `weight`, `image`, `category`, `created_at` FROM `products`";
$stmt = $db->prepare($sql);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($product_id, $name, $price, $description, $stock, $weight, $image, $category, $created_at);
$data = array();
while ($stmt->fetch()) {
$data[] = array(
'product_id' => $product_id,
'name' => $name,
'price' => $price,
'description' => $description,
'stock' => $stock,
'weight' => $weight,
'image' => $image,
'category' => $category,
'created_at' => $created_at
);
}
$data = json_encode($data);
$stmt->close();
$db->close();
echo $data;
}
?>