CREATE TABLE IF NOT EXISTS `guest_details` (
`name` varchar(15) NOT NULL,
`email` varchar(15) NOT NULL,
`cell` varchar(15) NOT NULL,
`roomtype` varchar(15) NOT NULL,
`checkin` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`checkout` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`adults` varchar(15) NOT NULL,
`numberofrooms` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `guest_details` (`name`, `email`, `cell`, `roomtype`, `checkin`, `checkout`, `adults`, `numberofrooms`)
VALUES
('sumanth', 'sumanth@gmail.c', '99999999999999', 'Single_AC', '2014-09-15 00:00:00', '2014-09-19 00:00:00', 'FGDFG', '2'),
('vijey', 'vijey.sk@gmail.', '222222222222222', 'Double_AC', '2014-09-21 00:00:00', '2014-09-24 00:00:00', 'lpuio', '1');
i need to retrive data from database between the checkin and checkout dates.My problem is dates are not compare. i am checking in mysql also.What is the problem i need solution.
$res = "select * from guest_details where checkin>=$date1 AND checkout<=$date1";
$res1 = mysql_query($res);
if ($res1)
/*while($row = mysql_fetch_array($res1))*/
{
echo $date1;
}
?>