-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
32 lines (29 loc) · 1.34 KB
/
ajax.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
<?php
require('lib/MySQLConnection.php');
if(isset($_GET['food-from-cat-id'])){
$query = "SELECT * FROM foods
WHERE food_category = " . $_GET['food-from-cat-id'] . " AND food_id > " . $_GET['food-from-cat-id'] . "
ORDER BY food_id ASC";
$food_result = $db->query($query) or die($db->error);
// probably should send json to client, but whatever
$html = "<select name='food-id' id='select-food-id'>";
while($row = $food_result->fetch_assoc()){
$html .= "<option value='".$row['food_id']."'>".$row['food_name']."</option>";
}
$html .= "</select>";
echo $html;
}
if(isset($_GET['sl-food-from-cat-id'])){
$query = "SELECT * FROM foods
WHERE food_category = " . $_GET['sl-food-from-cat-id'] . " AND food_id > " . $_GET['sl-food-from-cat-id'] . "
ORDER BY food_id ASC";
$food_result = $db->query($query) or die($db->error);
// probably should send json to client, but whatever
$html = "<select name='sl-food-id' id='select-food-id'>";
while($row = $food_result->fetch_assoc()){
$html .= "<option value='".$row['food_id']."'>".$row['food_name']."</option>";
}
$html .= "</select>";
echo $html;
}
?>