Hello everybody i am new to PHP and trying to learn more and more. now i am trying to make a reservation system i solved my date time problem but now i am stick on comparing two date from my form with two dates on my database here is my code and query :
form:
There is two textboxes one is Checkin and second is Checkout which i want to compare with stored dates in database.
And for that i am using following php code in same at the top:
if (isset($_POST['submit'])) {
$dt = date('yyyy-mm-dd', strtotime($_POST['Checkin']));
$dt1 = date('yyyy-mm-dd', strtotime($_POST['checkout']));
$errors = array();
// perform validations on the form data
$required_fields = array('Checkin', 'checkout');
$errors = array_merge($errors, check_required_fields($required_fields, $_POST));
$Chkin = trim(mysql_prep($_POST['Checkin']));
$Chkout = trim(mysql_prep($_POST['checkout']));
if ( empty($errors) ) {
$query = "SELECT checkin, checkout ";
$query .= "FROM bookd ";
$query .= "WHERE checkin BETWEEN $Chkin and $Chkout ";
$query .= "AND checkout BETWEEN $Chkout and $Chkout";
$result_set = mysql_query($query);
confirm_query($result_set);
if (mysql_num_rows($result_set) == 1){
$message = "Not avilable";
}
else{
$message = "avilable";
}
}
}
?>
So please tell me what should i do or there is any other way to get this happen. But please give me reply in brief because i am new to this language.