ok here is the query
$banner_report1 = "
SELECT categories.cat_id, categories.cat_name, categories.cat_parent, categories.cat_level, categories.cat_active, products.prod_id, products.prod_name, cat_products.id, test_codes.code
FROM categories
LEFT JOIN cat_products ON ( categories.cat_id = cat_products.cat_id )
LEFT JOIN products ON ( cat_products.prod_id = products.prod_id )
LEFT JOIN test_codes ON ( test_codes.code = products.prod_name )
ORDER BY cat_id ASC";
basically I got a categories table with a id - name - parent( id of parent category) etc
I'm displaying them like this
i.e.
chickens---------(id =1)
---eggs----------(id =2 & parent =1)
------green -----(id =3 & parent =2)
------red---------(id =4 & parent =2)
------spotted---(id =5 & parent =2)
---feathers-----(id =6 & parent =1)
------fluffy-------(id =7 & parent =6)
currently I'm repeating the query several times for every level of the categories...
hope this made it a bit clearer...