-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistRecipe.php
More file actions
59 lines (42 loc) · 1.74 KB
/
listRecipe.php
File metadata and controls
59 lines (42 loc) · 1.74 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
<!--
Michael Nunes Principles of Database System
Dr. Stephen Blythe 30500-21
Project #3
listRecipe.php
-->
<!--this php file is listing the ingredients and quantity from Recipe table where the recipe name is equal to the user input. And there listing in a table with a border of 4. Also, there is an option to go back to the main menu -->
<!--header of the page-->
<h1> List of ingredients and quantity </h1>
<?php
// to get data stored in a session, you must let the browser know to start a session
session_start();
// take data values from the session variables and store them
$host = $_SESSION["host"];
$user = $_SESSION["user"];
$pass = $_SESSION["pass"];
//remember, for our purposes the DB is the same as the username ...
$dbName = $user;
// build the connection ...
$conn = mysqli_connect($host, $user, $pass, $dbName);
// Get data from user
$recipe = $_POST["recipe"];
// find all matching recipename data
$queryString = "select Ingredient, Quantity from RecipeTable ".
" where RecipeName =\"$recipe\"";
$status = mysqli_query($conn, $queryString);
if (!$status)
die("Error running query: " . mysqli_error($conn));
//creating a table with a border of 4 with two column one of them for ingredients and another one for quantities
echo "<table border=4>";
echo "<tr> <th> Ingredients </th> <th> Quantities </th> </tr>";
while($row = mysqli_fetch_assoc($status))
{
echo "<tr> <td>".$row["Ingredient"]."</td>".
"<td>".$row["Quantity"]."</td> </tr>";
}
echo "</table>";
// close the connection (to be safe)
mysqli_close($conn);
//link to go back to the main menu
echo "<a href=MainMenu.html>Go back to the main menu</a>";
?>