Jump to content

Recommended Posts

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!!

Link to comment
https://forums.phpfreaks.com/topic/212826-google-directory/
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/212826-google-directory/#findComment-1108568
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.