madhavanrakesh Posted September 8, 2010 Share Posted September 8, 2010 Hi Guys!! I am in need of creating a categories' listing similar to that of Google Directory, http://www.google.com/dirhp All the categories along with their respective sub categories, subcategories of the subcategories, and the subsub categories of the subsub categories ( as deep down as the category system goes ) should be displayed which is exactly similar to that of the Google Directory. Could anyone suggest me how to do it as am pretty much new to PHP. The categories list is stored in a database and should be displayed using PHP and MySQL. This is exactly what i require. I have gone through some articles related to this, (both in this forum and elsewhere) but in all those tutorials, the depth of the categories is known (say, up to 4 or 5 levels). But, what i require is dynamic creation of these categories whose depth is unknown and also provide a way that any user can add a category from the front-end and also the admin can add a category from the back-end. Am in urgent need of this. Can anyone guide me in this regard, pls? And an example of the same would be of great help. Thanks in advance!! Quote Link to comment https://forums.phpfreaks.com/topic/212826-google-directory/ Share on other sites More sharing options...
HaLo2FrEeEk Posted September 8, 2010 Share Posted September 8, 2010 If you plan to display all these sub categories on a single page (unlike Google, which only displays two or three subcategories for each main category,) then you'll need to look into recursive functions. Basically the code runs over and over as deep as the tree goes until it hits an end, hen it goes back up to the next and prints the next sub-sub-sub whatever category. If you're looking to make it exactly like Google, where only a few sub categories are shown for each main category, then as you click a main category all the sub categories are shown (I'm getting really tired of typing the word category,) that'll be a lot simpler. You'll basically just pass the current category's name (or ID) to the script, which will look up all sub categories (or whatever is at the bottom, if there are no sub categories,) and print them to the page. All you'll need to define in the database is each sub category's parent category. Here's a very simple example: http://infectionist.com/tutorials/ This is a page on my own site that lists the different tutorial categories that I have available. Click on one of these main categories and you'll be presented with a page that lists each individual tutorial for that category. Seriously, tired of typing that word! Quote Link to comment https://forums.phpfreaks.com/topic/212826-google-directory/#findComment-1108568 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.