-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_availability.php
34 lines (30 loc) · 963 Bytes
/
table_availability.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
<?php
session_start();
include "templates/db-con.php";
$time = $_GET['time'];
$size = $_GET['size'];
$rest_id = $_GET['rest_id'];
$sql = "SELECT quantity from tables where rest_id = $rest_id && size = '$size';";
$result = mysqli_query($conn, $sql);
if(!$result){
die("QUERY FAILED ".mysqli_error($conn));
}
if(mysqli_num_rows($result) != 0){
$row = mysqli_fetch_assoc($result);
$max_tables = $row['quantity'];
}
$sql = "select COUNT(*) from reservations where rest_id = $rest_id and size = $size and date_time = '$time';";
$result = mysqli_query($conn, $sql);
if(!$result){
die("QUERY FAILED ".mysqli_error($conn));
}
if(mysqli_num_rows($result) != 0){
$row = mysqli_fetch_assoc($result);
$booked_tables = $row['COUNT(*)'];
}
if($booked_tables < $max_tables)
echo 'available';
else
echo 'not-available';
mysqli_close($conn);
?>