$appr2 = mysql_query("SELECT from_date FROM mrfs WHERE `mrf_id`='$row[0]'") or die (mysql_error());
			$appr3=mysql_fetch_row($appr2);
				$appr4 = mysql_query("SELECT to_date FROM mrfs WHERE `mrf_id`='$row[0]'") or die (mysql_error());
			$appr5=mysql_fetch_row($appr4);
			$date=date("m/d/Y");
			$date1=date("m/d/Y", strtotime("$appr3[0] -8 days"));
			
			if($date>=$date1 && $date<=$appr5[0] )

The code above says to compare two dates present date and from date
and present date and to date.
this works fine if i select any date in 2011 but not if i select any date in 2012 after changing 8 to any other value.
Pls help....

Your going to have to post more of your codeing, because on line 1

$appr2 = mysql_query("SELECT from_date FROM mrfs WHERE `mrf_id`='$row[0]'") or die (mysql_error());

im guessing you are running a sql query prior to that one? If you dont mind i have a suggestion

$result = mysql_query("SELECT from_date,to_date FROM people WHERE mrf_id = '$row[0]'");
if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}
$row = mysql_fetch_row($result);
$date = date("m/d/Y");
$from_date = date("m/d/Y", strtotime($row[0]-8 days"));
$to_date = $row[1];
if($date >= $from_date && $date <= $to_date) {

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.