-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_serve.php
More file actions
42 lines (32 loc) · 1.14 KB
/
add_serve.php
File metadata and controls
42 lines (32 loc) · 1.14 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
<?php
include("PhpMysqlConnectivity.php");
$r_id = $_POST['r_id'];
$name = $_POST['name'];
$price = $_POST['price'];
$discount = $_POST['discount'];
$vnv = $_POST['veg/nonveg'];
$q = "SELECT id FROM food WHERE name = '$name'";
$result = mysqli_query($link, $q);
$result = mysqli_fetch_array($result);
if(!$result){
$q = "INSERT INTO `food`(`name`, `type`) VALUES ('$name','$vnv')";
$result = mysqli_query($link, $q);
if(!$result){
echo 'something somewhere went wrong <br>'.$q.'<br>'.mysqli_error($link) ;
}
$q = "SELECT LAST_INSERT_ID();";
$f_id = mysqli_fetch_array(mysqli_query($link,$q))[0];
}
else{
$f_id = $result['id'];
}
$q = "INSERT INTO `serves`(`r_id`, `f_id`, `star`, `price`, `discount`) VALUES ($r_id,$f_id,3,$price,$discount)";
$result = mysqli_query($link, $q);
if($result){
echo 'done';
header('Location: '.'restaurant.php?r_id='.$r_id);
}
else {
echo '<br><h3>Something somewhere went wrong</h3> <br>'.$q.'<br>'.mysqli_error($link) ;
}
?>