-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-dishes.php
149 lines (129 loc) · 6.45 KB
/
load-dishes.php
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
//AJAX data - which data select
$insertDishes = $_POST['insertDishes'];
//AJAX data - dishes cards menu
if($insertDishes==1)
{
$newDishType = $_POST['newDishType'];
}
elseif($insertDishes==2)
{
$dishIdOrder = $_POST['dishIdOrder'];
}
//AJAX data - dishes order
//$dishIdOrder = $_POST['dishIdOrder'];
//$dishSizeOrder = $_POST['dishSizeOrder'];
class Dish
{
//Properies
public $id;
public $type;
public $name;
public $description;
public $price_s;
public $price_l;
//METHODS
//SETTERS
function set_id($id)
{
$this->id=$id;
}
function set_type($type)
{
$this->type=$type;
}
function set_name($name)
{
$this->name=$name;
}
function set_description($description)
{
$this->description=$description;
}
function set_price_s($price_s)
{
$this->price_s=$price_s;
}
function set_price_l($price_l)
{
$this->price_l=$price_l;
}
//GETTERS function get_id()
function get_id()
{
return $this->id;
}
function get_type()
{
return $this->type;
}
function get_name()
{
return $this->name;
}
function get_description()
{
return $this->description;
}
function get_price_s()
{
return $this->price_s;
}
function get_price_l()
{
return $this->price_l;
}
}
//import from connect.php
require_once "connect.php";
//check connection
if($connect->connect_error)
{
die("Connection filed: ".$connect->connect_error);
}
//if connection is correct, then execute the class
else
{
if($insertDishes==1)
{
$sql = 'SELECT id, type, name, description, price_s, price_l FROM dishes WHERE type="'.$newDishType.'"';
}
elseif($insertDishes==2)
{
$sql = 'SELECT id, type, name, description, price_s, price_l FROM dishes WHERE id="'.$dishIdOrder.'"';
}
//if($result = $connect->query($sql))
if($result = mysqli_query($connect, $sql))
{
if(mysqli_num_rows($result) > 0)
{
//output data of each row
while($row = mysqli_fetch_assoc($result))
{
$dish[$row['id']] = new Dish();
$dish[$row['id']]->set_id($row["id"]);
$dish[$row['id']]->set_type($row["type"]);
$dish[$row['id']]->set_name($row["name"]);
$dish[$row['id']]->set_description($row["description"]);
$dish[$row['id']]->set_price_s($row["price_s"]);
$dish[$row['id']]->set_price_l($row["price_l"]);
#echo "id: " . $row["id"]. "type: ".$row["type"] ." - Name: " . $row["name"]. " " . $row["description"]."- price - ".$row["price_s"]."<br>";
if($insertDishes==1)
{
include "menu-content.php";
}
elseif($insertDishes==2)
{
include "load-colected-dish-order.php";
}
}
}
$result->free();
}
else
{
echo "result error! Type of dishes: ".$newDishType;
}
$connect->close();
}
?>