Hierarchical reports, nested categories
My 1st post!
I am working an a php/mysql app in which I need to generate dynamic html reports that arrange data from the db in a 3-level hierarchy. I'm able to write the big-honkin'-query that pulls all the data I need (from multiple tables, w/keys to create relationships), but I'm having trouble presenting it. I can spew the data into an html table but all the categories, subcategories, etc get repeated for every record, like this:
Category1 | SubCat1
Category1 | SubCat2 | SubSub1 | data1
Category1 | SubCat2 | SubSub1 | data2
Category1 | SubCat2 | SubSub2
Category1 | SubCat3
I want my html report to be structured more like this:
I'm a relative newbie to php and to programming generally, tho am comfortable with SQL. I've played around with trying to nest 'while' statements, etc., but keep hitting walls. I won't bore you with all the real data/table structures I'm using, but here's an example:
*********** [highest level]
*********** [mid level]
The report wd look something like:
FROM order, genus, species
AND order.id=" . $_GET['order_id']);
I'm guessing there's a fairly simple way to do this but I'm stumped. Can anyone help?