hi all,
i am generting a report where i need to display the monthly wise reports iam not able to display correctly

<?php
ob_start();
include_once('login_check.php');

include_once('functions.php');
$mon=date("m");
$year=date("y");
 $num = cal_days_in_month(CAL_GREGORIAN, $mon, $year);



?>
<html>
<head> 
<title>..</title>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">

<link rel="stylesheet" type="text/css" href="../styles.css">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>

</head>
<body> 
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td height="1" colspan="3" align="right" bgcolor="#336699"><img src="../images/spacer.gif" width="1" height="1"></td>
  </tr>
  <tr>

  
	<td width="83%" align="left" valign="top">
	<table width="100%" border="0" cellspacing="0" cellpadding="1">
	  <form name="frmmagproprods" id="frmmagproprods" method="post"  enctype="multipart/form-data" >
	  <input type="hidden" name="hidcatnsubc" id="hidcatnsubc" value="true">
      <tr>
        <td colspan="2" align="center" valign="top" class="style12">&nbsp;</td>
      </tr>
      <tr>
        <td width="50%" align="center" valign="top" class="style12">&nbsp;</td>
        <td width="69%" align="center" valign="top" class="style12">&nbsp;</td>
        </tr>
      <tr>
        <td colspan="2" valign="top"><table width="90%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
            <td bgcolor="#336699"><table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#8CC7EA">
                <tr>
                  <td width="10%" nowrap bgcolor="#336699" class="text2">Month</td>
                  <? for($m=1;$m<=$num;$m++) {?> <td  bgcolor="#336699" class="style2"><? echo $m;?></td>
               <? }?> </tr>
		<? $tt=mysql_query("select u_res_date from tbl_users where u_id='".$_GET['u_id']."'");
$fetch=mysql_fetch_assoc($tt);
 $gg=$fetch['u_res_date'];
$hh= explode("-",$gg);

 $dateDiff2 = mktime(0,0,0,date('n'),date('d'),date('Y')) - mktime(0,0,0,$hh[1],$hh[2],$hh[0]);
$monthdiff=floor($dateDiff2/60/60/24/7/4);for($y=1;$y<=$monthdiff+1;$y++){
		?>
                 <tr >
                   <td rowspan="2" align="left" bgcolor="#FFFFFF" ><? echo date("Y-M",strtotime($gg));?></td>
				   <? //print_r($_SESSION);
				  $ord_date="";
				  $j="";
			
			$qur_ord=mysql_query("select date,user_id from `tbl_orders` where user_id='".$_GET['u_id']."' group by date");
			 
			while($row_ord=mysql_fetch_array($qur_ord)){
			$dateofg=explode(" ",$row_ord['date']);
				 $ord_date[$j][]=$dateofg[0];
			} 
  for($k=01;$k<=$num;$k++) {
				  
		$thisdate=date('Y-m-d',strtotime($gg));	  ?> 
					  <td height="25" align="center" <? if(!empty($ord_date[$j])){ if(in_array($thisdate,$ord_date[$j])) { echo "bgcolor='#00FF99'";} else { echo "bgcolor='#ffffff'";}} else  { echo "bgcolor='#ffffff'";}?>  ><? if(!empty($ord_date[$j])){ if(in_array($thisdate,$ord_date[$j])) { ?><a href="#" onClick="window.open('view_report_order.php?user_id=<?=$prow['u_id'];?>&date=<? echo $thisdate;?>','no','scrollbars=yes,width=700,height=500')"><? echo date("d",strtotime($thisdate));?></a><? }} ?></td><? }?>
                </tr>
				 <tr >
                   <? //print_r($_SESSION);
				  							
$ord_date2="";
$n=1;
		
			//echo "select distinct(ord_date),user_id from `tbl_perphoneorders` where user_id='".$_GET['u_id']."'";
			$qur_ord2=mysql_query("select date,user_id from `tbl_perphoneorders` where user_id='".$_GET['u_id']."' group by date");
			while($row_ord2=mysql_fetch_array($qur_ord2)){
			
			$dateoford=explode(" ",$row_ord2['date']);
			
			
				 $ord_date2[$n][]=$dateoford[0];
			} 

				  
  for($l=1;$l<=$num;$l++) {
				
				$thisdate=date('Y-m-d',strtotime($gg));	  ?> 
					  <td height="25" align="center" <? if(!empty($ord_date2[$n])){ if(in_array($thisdate,$ord_date2[$n])) {  echo "bgcolor='#F5AE5F'";} else { echo "bgcolor='#ffffff'";}} else  { echo "bgcolor='#ffffff'";}?>  ><? if(!empty($ord_date2[$n])){ if(in_array($thisdate,$ord_date2[$n])) {?><a href="#" onClick="window.open('view_report_order1.php?user_id=<?=$prow['u_id'];?>&date=<? echo $thisdate;?>','no','scrollbars=yes,width=700,height=500')"><? echo date("d",strtotime($thisdate));?></a><? }} ?></td><? }?>
                 </tr>
				 	<? if($hh[1]>12){$month=01;} 
				$next =  date("Y-m",strtotime($hh[0]."-".@$month."-1 +1 months"));
			$gg=$next; @$month++;
			}
					?>
				  
            </table></td>
          </tr>
        </table></td>
      </tr>
      
      <tr>
        <td colspan="2" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" valign="top">&nbsp;</td>
      </tr>
	  </form>
    </table></td>
  </tr>
  <tr>
    <td height="1" colspan="3" align="right" bgcolor="#336699"><img src="../images/spacer.gif" width="1" height="1"></td>
  </tr>
</table>
</body>
</html>

can any one please help me with this
thank you in advance

Can you explain better what it is you are trying to do, what result you expect and what result you are getting? Do you want to know how to calculate next month and next year as your subject implies, or is your question about writing reports?

yes,iam generating report of a user in shopping cart,user orders from the date he registered till now month wise

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.