Log in

View Full Version : Categories and subcategories


cinq
10-27-2003, 04:54 AM
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.

Brad
10-27-2003, 06:58 AM
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 :)

cinq
10-27-2003, 11:12 PM
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

Brad
10-28-2003, 12:33 AM
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) :)