I am creating a cooking app where there are categories and recipe within per category. So when the user tap the category BREAKFAST, all recipe will display that is assigned to BREAKFAST. To display that, it will depend in my php file but for the meantime it displays all same recipe(the whole recipe in the database) in every category and does not show the recipe depending on their assigned category.
I need your help how to display recipes depending on which category they are assigned(Example: Breakfast: Pancakes, soup. Lunch: soup,pizza. Dinner: pizza, burger). Reminder: the recipe can be also assigned to different categories... Thanks !
PHP FILE
<?php
require_once 'include/DB_Connect.php';
$db = new Db_Connect();
$conn = $db->connect();
if(isset($_GET['recipeId'])){
$id = $_GET['recipeId'];
$result = $conn->query("SELECT * FROM recipe where id=$id");
}else{
$result = $conn->query("SELECT * FROM recipe");
}
if ($result->num_rows > 0) {
$list = array();
while($row = $result->fetch_assoc()) {
array_push($list, $row);
}
echo json_encode(array('result' => $list));
} else {
echo json_encode("no result");
}
?>