FrostiE Posted March 11, 2006 Share Posted March 11, 2006 Hey, was wondering if someone could help me. Basically I am creating a gallery script with infinite subcategories. The only problem I have is this: For adding images, you have to select a category in the admin menu right? I want those categories to be aranged with all of a categories childeren underneath it. Something like this [img src=\"http://img224.imageshack.us/img224/3571/indent7am.jpg\" border=\"0\" alt=\"IPB Image\" /]If someone could help me with the code I would be REALLY grateful!!!Thanks Link to comment https://forums.phpfreaks.com/topic/4683-solved-sub-category-indenting/ Share on other sites More sharing options...
AndyB Posted March 11, 2006 Share Posted March 11, 2006 Code? To do what, exactly? Have you looked at using the standard html [a href=\"http://www.w3schools.com/tags/tag_optgroup.asp\" target=\"_blank\"]optgroup tag[/a]? Link to comment https://forums.phpfreaks.com/topic/4683-solved-sub-category-indenting/#findComment-16393 Share on other sites More sharing options...
FrostiE Posted March 11, 2006 Author Share Posted March 11, 2006 Well, basically I need to know how to retrieve all of the childeren under a category, not just the imediate ones, but childeren of childeren. Look at this image, it shows what I mean better:[img src=\"http://img58.imageshack.us/img58/6228/indent8gy.jpg\" border=\"0\" alt=\"IPB Image\" /]Obviously the ID depends on what order they where created as its auto_increment. Link to comment https://forums.phpfreaks.com/topic/4683-solved-sub-category-indenting/#findComment-16400 Share on other sites More sharing options...
Barand Posted March 11, 2006 Share Posted March 11, 2006 try[code]function listSubcats ($parent, $level=0) { $res = mysql_query ("SELECT category_id, name FROM categories WHERE parent = '$parent' ORDER BY name"); while (list($id, $name) = mysql_fetch_row($res)) { $indent = str_repeat('>', $level); echo "<OPTION value='$id'>$indent $name</OPTION>\n"; listSubcats($id, $level+1); }}echo "<SELECT name='cat'>";listSubcats(0);echo '</SELECT>';[/code] Link to comment https://forums.phpfreaks.com/topic/4683-solved-sub-category-indenting/#findComment-16402 Share on other sites More sharing options...
FrostiE Posted March 11, 2006 Author Share Posted March 11, 2006 Thanks so much. works perfectly !!!! Link to comment https://forums.phpfreaks.com/topic/4683-solved-sub-category-indenting/#findComment-16405 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.