southbeach
Programmer
I am working on a small project and for the first time, I find that the use of multi-level arrays is something I need to use.
My objective is to read through a flat file, render a printer ready page, show sub-totals within the pages and at the end, display a summary page.
The summary page needs to show the totals for two elements. Each element has three columns to total (by element I mean unique key or id).
The flat file looks like this:
shipper,cartons,kilos,volume,location,...
The summary page needs to look like this
SHIPPERS CTN KGS VOL
------------ ---- ---- -----
SHIPPER A 1 10 2.2
SHIPPER B 2 8 1.0
LOCATIONS CTN KGS VOL
------------ ---- ---- -----
LOC A 3 18 3.2
This is the PHP code I have to accumulate the summary data
and this is the code to display the summary data
Arrays are blank ... Count you please point out my problem?
Thank you all in advance!
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
My objective is to read through a flat file, render a printer ready page, show sub-totals within the pages and at the end, display a summary page.
The summary page needs to show the totals for two elements. Each element has three columns to total (by element I mean unique key or id).
The flat file looks like this:
shipper,cartons,kilos,volume,location,...
The summary page needs to look like this
SHIPPERS CTN KGS VOL
------------ ---- ---- -----
SHIPPER A 1 10 2.2
SHIPPER B 2 8 1.0
LOCATIONS CTN KGS VOL
------------ ---- ---- -----
LOC A 3 18 3.2
This is the PHP code I have to accumulate the summary data
Code:
$summaryA[$row[0]][0]=$row[0];
$summaryA[$row[0]][1]=+$row[2];
$summaryA[$row[0]][2]=+$row[3];
$summaryA[$row[0]][3]=+$row[4];
$summaryA[$row[12]][0]=$row[0];
$summaryB[$row[12]][1]=+$row[2];
$summaryB[$row[12]][2]=+$row[3];
$summaryB[$row[12]][3]=+$row[4];
and this is the code to display the summary data
Code:
for($x=0;$x<sizeof($summaryA);$x++) {
$shpsummary .= '
<tr>
<td>'.$summaryA[$x][0].'</td>
<td>'.$summaryA[$x][1].'</td>
<td>'.$summaryA[$x][2].'</td>
<td>'.$summaryA[$x][3].'</td>
</tr>';
}
for($x=0;$x<sizeof($summaryB);$x++) {
$locsummary .= '
<tr>
<td>'.$summaryB[$x][0].'</td>
<td>'.$summaryB[$x][1].'</td>
<td>'.$summaryB[$x][2].'</td>
<td>'.$summaryB[$x][3].'</td>
</tr>';
}
Arrays are blank ... Count you please point out my problem?
Thank you all in advance!
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.