If I understand correctly and you have the data all in one table,
you can just query all the data that goes into the report, sorted
by categories, and output the data in a loop. This code will give
you an ordered list indented and numbered by level. It's not
perfect, but give you the idea...

$qstr="SELECT * FROM table ORDER BY cat1, cat2, cat3";
while ($row = mysql_fetch_array($rslt)) {
        if ($cat1!=$row['cat1']) {
                echo "$indent $cat1<BR>";
        if ($cat2!=$row['cat2']) {
                echo "$indent $cat2<BR>";
        if ($cat3!=$row['cat3']) {
                echo "$indent $cat3<BR>";

Hope that helps.

Best regards,

Wednesday, March 26, 2003, 8:18:50 PM, you wrote:

> I have a table with a tree.  Thing is, I need to generate a view of it like:
> Category
>     Sub-category
>         Sub-sub-category
>     Another sub-category
> Another category
>   Sub-category

> Any way to do this, without using a huge number of queries?  Using MySQL.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to