Show sourcecode
The following files exists in this folder. Click to view.
webbsrvprg/projects/slutprojekt/
class/
create-categories.php
create-recipe.php
css/
db_content.php
forgot_password.php
include/
login.php
logout.php
recipe-search.php
recipe.php
reset_password.php
signin.php
start.php
tabeller/
verify.php
recipe-search.php
36 lines ASCII Windows (CRLF)
<?php
include ('../../dbconnection.php');
ob_clean();
$key = $_GET['recipe'];
$query = "SELECT r.* FROM recipes r
LEFT JOIN recipe_categories rc ON r.recipe_id = rc.recipe_id
LEFT JOIN categories c ON rc.category_id = c.category_id
WHERE r.title LIKE '%$key%'
OR r.ingredients LIKE '%$key%'
OR c.name LIKE '%$key%'
GROUP BY r.recipe_id
ORDER BY r.title";
$stmt = $dbconn->prepare($query);
$data = array();
$stmt->execute($data);
$output = "";
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
$recipe = $res["title"];
$recipe_id = $res["recipe_id"];
$img = $res["image"];
if (empty($img)) {
$img = '../../../filhantering/no-image.jpg';
}
$output.= "<a href='recipe.php?recipe=$recipe_id'><div class='recipe'> <img src='$img' alt='bild'> <p>$recipe</p> </div></a> ";
}
echo "$output";
?>