-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult.php
More file actions
129 lines (110 loc) · 4.11 KB
/
Copy pathresult.php
File metadata and controls
129 lines (110 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php require './includes/_dbconnect.php'; ?>
<?php $title = "Recipe Result";?>
<?php require './includes/_header.php'; ?>
<div class="recipeGridResult">
<?php
$id = isset($_GET["id"]) ? mysqli_real_escape_string($connection, $_GET["id"]) : null;
if (!$id) {
redirect_to("index.php");
}
else {
$query = 'SELECT * ';
$query .= 'FROM recipes ';
$query .= "WHERE id = '$id' ";
$query .= 'LIMIT 1';
}
$result = mysqli_query($connection, $query);
while ($row = mysqli_fetch_assoc($result)) {
if (!$result) {
die ("Database query failed.");
}
?>
<img class="resultImage" src="./media/recipeImages/<?php echo $row['images']; ?>/main_pic.jpg" alt="<?php echo $row['title']; ?>">
<br>
<h1 class="resultTitle"><?php echo $row['title']; ?></h1>
<h1 class="resultSide">with <?php echo $row['side']; ?></h1>
<p class="resultDescription"><?php echo $row['description']; ?></p>
<br>
<div class="miscInfo">
<h3>Nutrition</h3><p class="resultNutrition"><?php echo $row['nutrition']; ?> calories</p>
<br>
<h3>Cook Time</h3><p class="resultTime"><?php echo $row['time']; ?> minutes</p>
<br>
<h3>Serving Size</h3><p class="resultServing"><?php echo $row['servings']; ?></p>
</div>
<h3>Ingredients</h3>
<div class="resultIngredients">
<ol>
<?php
$ingredients = $row['ingredients'];
$ingredients_array = explode("\\", $ingredients);
for ($i = 0; $i < substr_count($ingredients, '\\'); $i++) {
?>
<li><?php echo $ingredients_array[$i]; ?></li>
<?php } ?>
</ol>
</div>
<br>
<img class="resultImageIngredients" src="./media/recipeImages/<?php echo $row['images']; ?>/ingredients.png" alt="Ingredients">
<h3 class="resultSteps">Steps</h3>
<div class="stepsImagesGrid">
<?php
$steps = $row['steps'];
$steps_array = explode("\\", $steps);
?>
<h2 class="stepNumbers"><?php echo $steps_array[0]; ?></h2>
<img src="./media/recipeImages/<?php echo $row['images']; ?>/step_01.jpg" alt="Step 1" class="stepsImages">
<br>
<p><?php echo $steps_array[1]; ?></p>
<br>
<h2 class="stepNumbers"><?php echo $steps_array[2]; ?></h2>
<img src="./media/recipeImages/<?php echo $row['images']; ?>/step_02.jpg" alt="Step 2" class="stepsImages">
<br>
<p><?php echo $steps_array[3]; ?></p>
<br>
<h2 class="stepNumbers"><?php echo $steps_array[4]; ?></h2>
<img src="./media/recipeImages/<?php echo $row['images']; ?>/step_03.jpg" alt="Step 3" class="stepsImages">
<br>
<p><?php echo $steps_array[5]; ?></p>
<br>
<h2 class="stepNumbers"><?php echo $steps_array[6]; ?></h2>
<img src="./media/recipeImages/<?php echo $row['images']; ?>/step_04.jpg" alt="Step 4" class="stepsImages">
<br>
<p><?php echo $steps_array[7]; ?></p>
<br>
<h2 class="stepNumbers"><?php echo $steps_array[8]; ?></h2>
<img src="./media/recipeImages/<?php echo $row['images']; ?>/step_05.jpg" alt="Step 5" class="stepsImages">
<br>
<p><?php echo $steps_array[9]; ?></p>
<br>
<h2 class="stepNumbers"><?php echo $steps_array[10]; ?></h2>
<img src="./media/recipeImages/<?php echo $row['images']; ?>/step_06.jpg" alt="Step 6" class="stepsImages" id="step6" onerror="this.style.display='none';">
<br>
<p><?php echo $steps_array[11]; ?></p>
<br>
</div>
<?php
}
// Release Returned Data
mysqli_free_result($result);
// Close Database Connection
mysqli_close($connection);
?>
</div>
<!-- Trigger/Open Modal -->
<button id="myBtn" onclick="helpMe();" title="Help">Help</button>
<!-- Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modalContent">
<div class="modalHeader">
<span class="close">×</span>
<h2 class="modalTitle">Instructions</h2>
</div>
<div class="modalBody">
<p>Use the search bar to find what you are looking for, or find a recipe by using the filters above.</p>
</div>
</div>
</div>
<script src="javascript.js"></script>
<?php require './includes/_footer.php'; ?>