Skip to content
Snippets Groups Projects
Commit 1125c1ec authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

can search ingredients

parent 241e3ebb
No related branches found
No related tags found
No related merge requests found
......@@ -217,21 +217,22 @@ function getRecettes($search=""){
// https://stackoverflow.com/a/18603279
$categoryId = $search["categoryId"] ?? "";
$name = $search["name"] ?? "";
$ingredientId = $search["ingredientId"] ?? "";
$ingredients = $search["ingredients"] ?? "";
$difficulte = $search["difficulte"] ?? "";
$tempsPreparation = $search["tempsPreparation"] ?? "";
$auteurId = $search["auteurId"] ?? "";
// On construit la requête
$queryString = "SELECT * FROM m_recette WHERE 1=1";
$queryString = "SELECT * FROM m_recette INNER JOIN m_recetteIngredient ON m_recette.id=m_recetteIngredient.recetteId WHERE 1=1";
if(!empty($categoryId)){
$queryString .= " AND categoryId=:categoryId";
}
if(!empty($name)){
$queryString .= " AND nom LIKE :name";
}
if(!empty($ingredientId)){
$queryString .= " AND ingredientId=:ingredientId";
if(!empty($ingredients)){
$ingredientsIn = implode(',', $ingredients);
$queryString .= " AND ingredientId IN (:ingredients)";
}
if(!empty($difficulte)){
$queryString .= " AND difficulte=:difficulte";
......@@ -254,7 +255,7 @@ function getRecettes($search=""){
$query->bindParam(':name', $name);
}
if(!empty($ingredientId)){
$query->bindParam(':ingredientId', $ingredientId);
$query->bindParam(':ingredients', $ingredientsIn);
}
if(!empty($difficulte)){
$query->bindParam(':difficulte', $difficulte);
......
......@@ -20,8 +20,8 @@
<!-- Recettes -->
<div class="container">
<div class="filtreRecettes bg-light my-5">
<h5>Filtre</h5>
<div class="filtreRecettes p-2 bg-light my-5">
<h5><strong>Filtre</strong></h5>
<div class="row">
<div class="col-sm">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment