in reply to Unlimited groups/categories

I'm not sure I've understand your problem: it seems you want an algorithm for printing your groups tree.

The most obvious way to do so is to write a recursive sub which print all the groups with a given value of subgroups:

You define a sub, let's call it "scan" which takes two arguments "$subGroup" and "level". The sub does a SQL select of all groups with subgroup=$subgroup ordered as you like; for each row of the dataset, it prints gname preceeded by $level ">" and then calls itself passing as arguments the value of id for the row and $level+1.

Careful with that hash Eugene.