ApiDrkDdl/Neu/modules/Ingredients.php
2025-01-24 21:08:32 +01:00

22 lines
502 B
PHP

<?php
require_once __DIR__ . '/../config.php';
function get_ingredients_by_recipe($recipe_id) {
$conn = db_connect();
$sql = "SELECT * FROM Ingredients WHERE RecipeId = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $recipe_id);
$stmt->execute();
$result = $stmt->get_result();
$ingredients = [];
while ($row = $result->fetch_assoc()) {
$ingredients[] = $row;
}
$stmt->close();
$conn->close();
return json_encode($ingredients);
}
?>