i Have this code for a start.

Code:
$query="Select tblamountalloc.agencycode,tblamountalloc.nproject,tblamountalloc.projectname,
tblamountalloc.Location1,tblamountalloc.Location2,tblamountalloc.Location3,tblnojobs.Location1,
tblnojobs.Location2,tblnojobs.Location3 from tblamountalloc Inner join tblnojobs on 
tblamountalloc.projectname=tblnojobs.projectname
where tblheader.starperiod between '2012-06-01' and '2012-08-01'";

Code:
while ($record = mysql_fetch_object($query)) {
  $set[$record->agencycode][$record->nproject[0]][$record->projectname][] = $record;
}
ksort($set);

print "<table>\n";
foreach ($set as $agency => $agencycodes) {
 print "<h2>{$agency}</h2>\n";
foreach ($agencycodes as $agencycode => $procodes) {
  foreach ($procodes as $procode => $qrtcodes) {
  print "<tr>";
  print "<th>{$procode}</th><th>&nbsp;</th>";

  foreach ($qrtcodes as $records) {
  	
  	$mono=$records->qrtcode;
        $sno= remove_non_numeric($mono);   
        $monumber=substr($sno,0,-4);
       
 	$ncr[$monumber]=$records->ncra;	 	
 	
  }

 unset($qrtcodes);
	  
print "<th>".array_sum($ncr)."</th>"; 	
  foreach ($ncr as $ncrrecords) {  	 
        print "<th>{$ncrrecords}</th>";
  }
  unset($ncr);
    
  
  print "<tr>";
  }
}
}
print "</table>\n";
the code above have the result of like this.


Code:
Project III (ARISP III)	         900	100.00	300.00	500.00
Support Project III (ARISP III)	 200	200.00
Project II (ARCP II) (Infra)	 600	600.00
my problem is my display should be like this
Code:
  
                                    Total   June         July           August
Project III (ARISP III)	           900	    100.00	  300.00	 500.00
Support Project III (ARISP III)   200	    200.00         0.00        0.00
Project II (ARCP II) (Infra)	   600	   0.00          0.00        600.00
I want to insert 0.00 in an array where the project doesnt have a record within a date of a date range.