I'm making a table right now for displaying accounting data, with invoices broken up into license, year, half, and quarter. The invoices come from a query as a 2d array,like this:
array(
'invoice0' = array(data),
'invoice2' = array(data),
'invoice3' = array(data),
'invoice4' = array(data),
'invoice5' = array(data),
'invoice1' = array(data)
)
Currently I'm been using a four-deep nested foreach loop, which seems fairly evil, to create a 5d array structure to organize the rows, with data rows for every level. e.g.:
'License' = array(
'Year0' = array(
'Half0' = array(
'Quarter0' = array(
'invoice0' = array(data),
'invoice1' = array(data)
),
'QData' = array(data)
),
'HData' = array(data)
'Half1' = array(
'Quarter0' = array(
'invoice3' = array(data),
'invoice4' = array(data)
),
'Quarter1' = array(
'invoice5' = array(data),
'invoice6' = array(data)
),
'QData' = array(data)
),
'HData' = array(data)
),
'YData' = array(data)
)
And so on. The data for each level needs to include a sum of an amount in the data for each invoice. The end product I'm trying to achieve is simply a bunch of rows of a table (or list items; I'm restricted to table structure for this project) That are expandable. So:
<tr>License info</tr>
<tr>License info</tr>
<tr>License info</tr>
<tr>License info</tr>
And when you click on one:
<tr>License info</tr>
<tr>License info</tr>
<tr>Year1 Info</tr>
<tr>Year2 Info</tr>
<tr>Year3 Info</tr>
<tr>License info</tr>
<tr>License info</tr>
Eventually:
<tr>License info</tr>
<tr>License info</tr>
<tr>Year1 Info</tr>
<tr>Year2 Info</tr>
<tr>Half1 Info</tr>
<tr>Quarter1 Info</tr>
<tr>Quarter2 Info</tr>
<tr>Invoice1 Info</tr>
<tr>Invoice2 Info</tr>
<tr>Invoice3 Info</tr>
<tr>Quarter3 Info</tr>
<tr>Quarter4 Info</tr>
<tr>Half2 Info</tr>
<tr>Year3 Info</tr>
<tr>License info</tr>
<tr>License info</tr>
So, any ideas? Is there any way to avoid such complex data manipulation while still getting me a 5-deep hierarchical dropdown list?