我需要一个验证功能来检查 可用的酒店客房(用于指定的地点/酒店和指定的日期/时间段,可能是指定的房间类型。
我在想这样的事情,但是我还没有使它起作用:
$sql="SELECT *
FROM bookings
WHERE date_begin <= '$checkin' AND date_end >= '$checkout'
表格
CREATE TABLE user
(
username VARCHAR(20),
password VARCHAR(20),
PRIMARY KEY(username)
);
CREATE TABLE hotel
(
hotelname VARCHAR(30) NOT NULL,
place VARCHAR(30),
PRIMARY KEY(hotelname)
);
CREATE TABLE roomtype
(
roomtype VARCHAR(30) NOT NULL,
PRIMARY KEY(roomtype)
);
CREATE TABLE hotelroomtype
(
hotelname VARCHAR(40),
roomtype VARCHAR(50),
numberofrooms INT(3),
PRIMARY KEY (hotelname, roomtype),
FOREIGN KEY(hotelname) REFERENCES hotel(hotelname),
FOREIGN KEY(roomtype) REFERENCES roomtype(roomtype)
);
CREATE TABLE room
(
hotelname VARCHAR(40),
roomtype VARCHAR(50),
roomnumber INT(3),
PRIMARY KEY (hotelname, roomnumber),
FOREIGN KEY(hotelname, roomtype) REFERENCES hotelroomtype(hotelname,
roomtype)
);
CREATE TABLE bookings
(
orderid INT(1000) auto_increment,
username VARCHAR(40),
hotelname VARCHAR(50),
roomtype VARCHAR(3),
numberofrooms INT(3),
checkin DATE,
checkout DATE,
PRIMARY KEY(orderid),
FOREIGN KEY(username) REFERENCES user(username),
FOREIGN KEY(hotelname) REFERENCES hotel(hotelname)
);