View Full Version : Categories and subcategories
Am currently working on a hack which would require the use of subcategories.
How can I go about with this ?
As it is , the sql end has a table for the categories.
Need I create another table for subcategories ?
Am pretty lost as to where to begin.
Any help would be most appreciated.
The best way to do this is to add a new colum to the categories table called 'parentid'. 'parentid' will contain the id of the of the categorie your sub-cat belongs to.
Dean C
10-27-2003, 10:16 AM
You need to do some reading about recursive functions. I had to do this for my [top secret] project I'm working on but I did it but I have no idea how it works ;) Basically when you make your function youc all the function within it but that's essential to learning how to do this kind of thing :)
Basically when you make your function youc all the function within it but that's essential to learning how to do this kind of thing :)
Thanks Mist, I know what recursive functions are , but arggghh i hate using them in programming lol :p
But even then I do not quite see how they can be used for sub cats ... could you elaborate further ? :)
The best way to do this is to add a new colum to the categories table called 'parentid'. 'parentid' will contain the id of the of the categorie your sub-cat belongs to.
Thanks Brad.
What happens if a cat is not a subcat, ie a parent category ?
Sorry but am pretty new to this :o
Set it to something like '0' by default when they are created if they are not a sub-cat.
Dean C
10-28-2003, 10:17 AM
What brad said ^^ (I use -1 for some odd reason though) :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.