risingfree Posted February 23, 2009 Share Posted February 23, 2009 Hi, Ok, I'm addicted and looking for some help I've been trying all day to get something working, couple of things that go a bit beyond what I already know. First thing is a category menu in a form, so that a category can be chosen. I can do that but I need to display these hierarchicaly. This is what I have Table fields - CatID, CatName, CatParent, Query mysql_select_db($database_members, $members); $query_Recordset1 = "SELECT * FROM bus_categories ORDER BY CatName ASC"; $Recordset1 = mysql_query($query_Recordset1, $members) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); Display <select name="CatID"> <?php do { ?> <option value="<?php echo $row_Recordset1['CatID']?>" <?php if (!(strcmp($row_Recordset1['CatID'], $row_Recordset1['CatID']))) {echo "SELECTED";} ?>><?php echo $row_Recordset1['CatName']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </select> That all works fine to display all the categories and the form works displaying like: arts & crafts However, because some categories are repeated I need to display this like: Angus - Arbroath - arts & crafts Can anyone help me with this? I know I need to do a recursive query and I've been looking at a lot of examples but I'm just confusing myself. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.