i have online store and i want to make an api for it
i have a three tables in MySql database i Should use to fetch the product details
file_path
for the product image url
invetory_details
for price
tbl_product
for the product details like (name , description, digital or physical...etc)
i didn't know how to fetch data from more than one table please help me with this.
this is my code i was able to fetch data from one table
define('DB_HOST','localhost');
define('DB_USER','admin');
define('DB_PASS','123456');
define('DB_NAME','testname');
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()){
die('error'.mysqli_connect_error());
}
$stmt = $conn->prepare( "SELECT id, upc_code, category_id, sub_category_id, sub_subcategory_id, name, description, brand_id , digital, license_key_code, active , added_by_id, sort_order, rating, added_at, updated_at FROM tbl_product;");
$stmt->execute();
$stmt->bind_result($id, $upc_code, $category_id, $sub_category_id, $sub_subcategory_id, $name, $description, $brand_id, $digital, $license_key_code, $active, $added_by_id, $sort_order, $rating, $added_at, $updated_at);
$product= array();
while($stmt->fetch()){
$temp=array();
$temp['id']=$id;
$temp['upc_code']=$upc_code;
$temp['category_id']=$category_id;
$temp['sub_category_id']=$sub_category_id;
$temp['sub_subcategory_id']=$sub_subcategory_id;
$temp['name']=$name;
$temp['digital']=$digital;
$temp['active']=$active;
$temp['added_by_id']=$added_by_id;
$temp['sort_order']=$sort_order;
$temp['rating']=$rating;
$temp['added_at']=$added_at;
$temp['updated_at']=$updated_at;
array_push($product, $temp);
}
echo json_encode($product);