-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddDish.php
More file actions
65 lines (59 loc) · 1.99 KB
/
addDish.php
File metadata and controls
65 lines (59 loc) · 1.99 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
<?php include("header.php");
include("dbconnect.php");?>
<div id="body" style="padding: 0">
<?php $query = $_GET["query"]; ?>
<h1 class="textshadow"><a href="index.php" class="text" style="color: white;">Add Dish</a> » "<?php echo $query; ?>"</h1>
<ul data-role="listview">
<?php
// Search for query among recipe titles
echo "<li>DISHES</li>";
$result = mysql_query("SELECT * FROM recipe where recipe_name like '%$query%'")
or die(mysql_error());
$count = 0;
while ($row = mysql_fetch_assoc($result)) {
$count++;
$recipeId = $row['id'];
$recipeName = $row['recipe_name'];
$photo = $row['photo'];
$time = $row['time'];
echo "<li><a href='dish_details.php?query=$recipeId' data-rel='dialog' data-transition='pop'>" .
"<img src='images/thumbs/$photo.png' />" .
"<h3>$recipeName</h3>" .
"<p>$time</p>".
"</a></li>";
}
if ($count == 0) echo "<li>No dishes found.</li>";
echo "<li>MEALS</li>";
$result = mysql_query("SELECT * FROM public_meals where tags like '%$query%'")
or die(mysql_error());
$count = 0;
while ($row = mysql_fetch_assoc($result)) {
$count++;
$meal_id = $row['id'];
$meal_name = $row['name'];
$meal_dishes_str = $row['recipes'];
$dishes = explode(" ", $meal_dishes_str);
$name_str = "";
echo "<li><a href='dish_details.php?type=meal&query=$meal_id' data-rel='dialog' data-transition='pop'>";
foreach($dishes as $dishId) {
$result_dish = mysql_query("SELECT * FROM recipe where id = '$dishId'")
or die(mysql_error());
while ($row_dish = mysql_fetch_assoc($result_dish)) {
$photo = $row_dish['photo'];
$name = $row_dish['recipe_name'];
$name_str .= $name . " ";
}
}
echo "<img src='images/thumbs/$photo.png' />" .
"<h3>$meal_name</h3><p>$name_str</p></a></li>";
}
if ($count == 0) echo "<li>No meals found.</li>";
mysql_close($dbhandle);
?>
</ul>
</div> <!--END BODY -->
<div data-role="footer" class="ui-bar">
<a href="index.php" data-role="button" data-icon="back">Back</a>
</div>
</body>
</html>