I am making a cross-tab report where essentially the data has to be turned sideways (rows to columns). My approach was to create a blank template object, cycle through the data and fill in the cells of the printed report. Making page breaks when the returned query data exceeded the size of the page template.
For the fixed header information I have no trouble but when I try to create an array in the object to hold the variable number of column data, I cannot figure out how to reference / fill in the template.
How do I reference the array I created in the pObj object? see code below.
The following code illustrates my feeble attempt to do this. Ok this example is actually trying to use an array to store all the stuff. But I did try to use an object also.
For the fixed header information I have no trouble but when I try to create an array in the object to hold the variable number of column data, I cannot figure out how to reference / fill in the template.
How do I reference the array I created in the pObj object? see code below.
The following code illustrates my feeble attempt to do this. Ok this example is actually trying to use an array to store all the stuff. But I did try to use an object also.
Code:
function makePageObject($result, $row){
global $cPageCnt, $cRecCnt,$cBoring;
$pObj = array();
$pObj = array(
/*
------------------------------------------
page header info for specific boring
found in each row but only used on header
------------------------------------------
*/
$jobId = $row["jobid"],
$boring = $row["boring"],
/*
------------------------------------------
data section of page is a 11 X 22 table.
data can be more, less or equal to size of table
so I create an array with blanks
initialize array with blanks
------------------------------------------
*/
$colArray = array_fill(0, 22, array_fill(0, 10, " "))
);
//detail sample info for boring
while ($row = $result->fetch_array() and $cBoring == $row["boring"] and $cRecCnt < 11 )
{
/*
--------------------------------
build one column of sample data
for each boring up to 10 samples
per page
[B]How do I reference the array I
created in the pObj object?[/B]
--------------------------------
*/
[B]$colArray[/B][0][$cRecCnt] = $row["boring"];
$colArray[1][$cRecCnt] = $row["sample"];
$colArray[2][$cRecCnt] = $row["depth"];
$colArray[3][$cRecCnt] = $row["blows"];
$colArray[4][$cRecCnt] = $row["sampleType"];
$colArray[5][$cRecCnt] = $row["contNumb"];
$colArray[6][$cRecCnt] = $row['WWofSC'];
$colArray[7][$cRecCnt] = $row['DWofSC'];
$colArray[8][$cRecCnt] = $row['contWeight'];
$colArray[9][$cRecCnt] = $row['moisture'];
$colArray[10][$cRecCnt] = $row['sampleInAir'];
$colArray[11][$cRecCnt] = $row['sampleInWater'];
$colArray[12][$cRecCnt] = $row['water'];
$colArray[13][$cRecCnt] = $row['dryUnit'];
$colArray[14][$cRecCnt] = $row['dimDryUnit'];
$colArray[15][$cRecCnt] = $row['dimWeight'];
$colArray[16][$cRecCnt] = $row["dimDiameter"];
$colArray[17][$cRecCnt] = $row["qu"];
$colArray[18][$cRecCnt] = $row["percentFail"];
$colArray[19][$cRecCnt] = $row["qp"];
$colArray[20][$cRecCnt] = $row["tv"];
$colArray[21][$cRecCnt] = $row["soilDesc"];
//advance
$cRecCnt ++;
}
return $pObj;
}
Comment