$sql="select * from tbl_order where ord_date between '$date1' and '$date2'";
$res=mysql_query($sql);
$result=mysql_fetch_array($res);
$ord_id=$result[ord_id];
$sql2="select * from tbl_order_detail inner join tbl_product where tbl_order_detail.pd_id=tbl_product.pd_id and tbl_order_detail.ord_id='$ord_id'";
$res2=mysql_query($sql2);
$sql="select ord_date from tbl_order";
$res=mysql_query($sql);
$result=mysql_fetch_array($res);
$arr=explode("-",$result[ord_date]);
$d=$arr[0];
$m=$arr[1];
$y=$arr[2];
$day="$m-$y";
$result[ord_date]=$day;
$sql2="select tbl_order_detail.pd_id,sum(tbl_order_detail.ord_qty) as sum_qty,tbl_order_detail.ord_price,tbl_product.pd_name from tbl_order_detail inner join tbl_product inner join tbl_order where tbl_order_detail.pd_id=tbl_product.pd_id and tbl_order_detail.ord_id=tbl_order.ord_id and tbl_order.ord_date='$day' and tbl_order.ord_date like '$date1' group by tbl_order_detail.pd_id";
$res2=mysql_query($sql2)or die(mysql_error());
$sql="SELECT * FROM tbl_order WHERE YEAR(ord_date)='$year1'
and MONTH(ord_date)='$mount1'";
$res=mysql_query($sql);
$result=mysql_fetch_array($res);
$ord_id=$result[ord_id];
$sql2="select tbl_order_detail.pd_id,sum(tbl_order_detail.ord_qty) as sum_qty,tbl_order_detail.ord_price,tbl_product.pd_name from tbl_order_detail inner join tbl_product where tbl_order_detail.pd_id=tbl_product.pd_id and tbl_order_detail.ord_id='$ord_id' group by tbl_order_detail.pd_id";
$res2=mysql_query($sql2)or die(mysql_error());