Could any one plz tell me what's wrong with my code
My sql select while loop is not checking date range that's been inserted into the form.
<?php
if(isset($_POST['start'])&& ($_POST['end'])){
$user_id = $_SESSION['user_id'];
$leave_type= $_POST['leave_type'];
$comments= $_POST['comments'];
$start=date('Y-m-d',strtotime($_POST['start']));
$end=date('Y-m-d',strtotime($_POST['end']));
echo $start,'',$end;
**$checkdate = "SELECT * FROM emp_status WHERE user_id='$_SESSION[user_id]' AND ((start<='$_POST[start]'AND end>'$_POST[start]')
or
(start < '$_POST[end]'AND end >='$_POST[end]'))";
$query = mysql_query($checkdate);
$numrows=mysql_num_rows($query );
if ($numrows!=0)
{
while ($row= mysql_fetch_assoc($query))
{
$dbstart=$row ['start'];
$dbend= $row['end'];**
$user=$row ['user_id'];
}
// check to see if they match;
if ($user===$user_id && $dbstart===$start)
{
echo "you already have applied leave this period";
}
else{
$sql_insert = "INSERT into emp_status
(leave_type,user_id,start,end,comments,status)
VALUES ('$leave_type','$_SESSION[user_id]','$start','$end','$comments','pending')";
mysql_query($sql_insert) or die("Insertion Failed:" . mysql_error());
}
}