The Mysql query in PHP gives 0 records where as the query shows 5 records in Mysql.
Code in PHP is
$fromdate=trim($_POST['fromdate']);
$from=date('d-m-Y',strtotime($fromdate));
$todate=trim($_POST['todate']);
$to=date('d-m-Y',strtotime($todate));
$supname=$_POST['supplier'];
$sql="select a.date,(select itemname from items where itemid=a.itemid) as item,a.quantity,a.rate,a.fat,a.amount from purchasedetails a where a.supplierid=".$supname." and (a.date >='".$from."' and a.date <='".$to."')";
$result=mysql_query($sql);
$count=mysql_num_rows($result)
echo $count;
Query in Mysql
select a.date,(select itemname from items where itemid=a.itemid) as item,a.quantity,a.rate,a.fat,a.amount from purchasedetails a where a.supplierid=2 and a.date>='01-12-2012' and a.date<='10-01-2013';
date column in Mysql table is varchar type.