I am new to codeigniter. Now I am developing a hotel room booking system. Now I am facing some issues in checking the availability of rooms while booking.
My Query for checking room availability
$cindt = $this->input->post('myCheckInDate');
$coutdt = $this->input->post('myCheckOutDate');
$roomid = $this->input->post('room');
$this->db->select('*');
$this->db->from('booking');
$this->db->where("b_room", $roomid);
$this->db->where('b_cin <= ',$cindt);
$this->db->where('b_cout <= ',$cindt);
$this->db->where('b_cout >= ',$coutdt);
$this->db->where('b_cin >= ',$coutdt);
$query = $this->db->get();
$nn=$query->result_array();
//print_r($nn); exit();
if($nn){
$this->session->set_flashdata('yes', 'Rooms is not Available');
redirect($_SERVER['HTTP_REFERER']);
}
$cindt = $this->input->post('myCheckInDate');
$coutdt = $this->input->post('myCheckOutDate');
$roomid = $this->input->post('room');
$this->db->select('*');
$this->db->where('b_cin >=', $cindt);
$this->db->where('b_cout <=', $coutdt);
$this->db->where('b_room', $roomid);
$this->db->from('booking');
$nn = $this->db->get()->result();
if($nn > 0){
$this->session->set_flashdata('yes', 'Rooms is not Available');
redirect($_SERVER['HTTP_REFERER']);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.