your question on heirarchical displays is primarily a javascript issue - go to many car parts websites and you can see great examples of dropdown menus/options appearing based on the parent selection - either you can load all the heirarchy in a javascript array, or you can send a signal onchange() for the dropdown, to an iframe or by ajax. You are taking on one of the more advanced projects there is, so I suggest you write out a game plan on this and start with a single step. You can have the query string "set" all values in the tree if you wish to show the page already drilled-down, so
<select name="maincat">
<option value='1' <?php echo $maincat==1?'selected':''?>>option 1</option>
<option value='2' <?php echo $maincat==2?'selected':''?>>option 2</option>
<option value='3' <?php echo $maincat==3?'selected':''?>>option 3</option>
<option value='4' <?php echo $maincat==4?'selected':''?>>option 4</option>
.. etc.
</select>