forked from divyamamgai/Naveta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquantity.php
23 lines (23 loc) · 868 Bytes
/
quantity.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
function updateSeat(){
$id = $_GET['BusID'];
$SeatQuantity = $_GET['Quantity'];
$dbuser = 'root';
$dbname = 'naveta';
$dbpass = '123456789';
$dbhost = 'localhost';
mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die(mysql_error());
$query = "Update `bus` SET `AvailableSeats`=`AvailableSeats`+$SeatQuantity WHERE `BusID`=$id";
$result = mysql_query($query) or die(mysql_error());
$query = "Select `AvailableSeats` FROM `bus` WHERE `BusID`=$id";
$result = mysql_query($query) or die(mysql_error());
$num = mysql_fetch_object($result);
if($num)
{
$query = "Update `bus` SET `AvailableSeats`=0 WHERE BusID=$id";
}
$result = mysql_query($query) or die(mysql_error());
}
updateSeat();
?>