Author |
Topic  |
|
MaD2ko0l
Senior Member
   
United Kingdom
1053 Posts |
Posted - 30 August 2007 : 18:51:48
|
hiya, i have a little project goin on for a image gallery that can have many sub categories and what i am trying to do is show a category and then the sub categories under that category
it would prbly look like this
category1 >subcat1 >>subcat1 >subcat2 category2 >subcat1
etc etc
this is what my table looks like and it is called "GALLERY_CATEGORYS"

can anyone point me in the right direction on how i coudl achieve what i am tryign to do?
thanks
MaD2ko0l |
© 1999-2010 MaD2ko0l |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 30 August 2007 : 19:09:00
|
Not sure that I understood what you want, because the text sample is not coherent with the DB sample. Maybe you can give a text example based on the actual contents of the DB and that should help me understand it.
Am I right in thinking you have just two levels here (Cat and subcat) or can subcats be parents too?
What is your problem specifically? The DB structure, retrieving the data or just showing it? |
Snitz 3.4 Readme | Like the support? Support Snitz too |
 |
|
MaD2ko0l
Senior Member
   
United Kingdom
1053 Posts |
Posted - 30 August 2007 : 20:51:45
|
ok, sorry
using the current data in the database i would want it to look somthing like this
category1 >subcat1 category2 >subcat2
so category1 = "Image Gallery" category2 = "Image gallery2" subcat1 = "gallery3" subcat2 = "gallery4"
does that make it clear?
so i would like the categories/subcategories displayed like the text sample so that u can tell if a category has any subcategories
at the moment, to see a subcategory u have to go into the category (eg image gallery1) to see if it has any subcategories, and then the subcategories can have subcategories in them as well.
http://www.gamingcrypt.co.uk/gallery.asp?CID=14&cType=1 if u go here and click on the "test" category u should be able to see how it works at the moment, but there is no way to see if a category has any subcategories without broswing then first
hope that helps u a bit more.
thanks
MaD2ko0l |
© 1999-2010 MaD2ko0l |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 30 August 2007 : 21:14:57
|
If you have categories that have subcategories, that can have, themselves, subcategories, you have a recursive structure. Relational databases do not handle recursiveness that well and in order to find out what you want, you need to run several queries:
the first query finds the children for the level 1 categories and then you need to run a query to find the children of the children and so on...
I'd say you'd better limit the depth of the hierarchy or you will be facing quite a difficult task. |
Snitz 3.4 Readme | Like the support? Support Snitz too |
 |
|
MaD2ko0l
Senior Member
   
United Kingdom
1053 Posts |
Posted - 30 August 2007 : 21:16:32
|
ok...thats ko0l...i will go away and have a rethink and look at some examples.
thanks for the help
MaD2ko0l |
© 1999-2010 MaD2ko0l |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 30 August 2007 : 21:17:26
|
Gee, this sounds an awful lot like the same discussion regarding the sub-form MOD.  |
 |
|
MaD2ko0l
Senior Member
   
United Kingdom
1053 Posts |
Posted - 30 August 2007 : 21:59:35
|
i did have a look at that as well. i was trying to go for an unlimited ammount of subcategories. |
© 1999-2010 MaD2ko0l |
 |
|
gary b
Junior Member
 
USA
267 Posts |
Posted - 31 August 2007 : 07:50:33
|
Never the bashful one, allow me to make a suggestion. Although not as astute as many members, I am 'devious'!
Your posts describe a multi-level heirarchical relationship between tables. Why not use flat with one or more "descriptors"? There would be no limit to the number of categories, sub-categories, sub-sub-categories, etc...
Ex for pictures: (periods used to separate columns) Cat......sub1......sub2......sub3.......link <= Table field names space....earth.....land......[Null]...../images/Namerica.jpg space....earth.....land......[Null]...../images/Samerica.jpg space....earth.....land......forests..../images/xx.jpg space....earth.....land......cities...../images/yy.tif space....planets...[Null]....[Null]...../images/aa.jpg space....planets...exoplanets.[Null]..../images/bb.jpg people...atwork....[Null]....[Null]...../images/cc.jpg people...athome....[Null]....[Null]...../images/dd.jpg
You *could* get by with only first two columns/data fields. By doing a query for distinct values of sub3 with space/earth/land as criteria, the row count would tell you how many 'sub-categories' there are.
Hopefully, I have been able to convey my idea. If the approach is way off base, remember: we are only slightly past a full moon! 
Edit: Add 'link to picture' column |
Edited by - gary b on 31 August 2007 08:02:54 |
 |
|
PPSSWeb
Junior Member
 
312 Posts |
Posted - 31 August 2007 : 09:58:27
|
This may be way off track, but how are the images stored? Are you allowing users to upload to the file system? If so, couldn't you use the file system directory structure itself to create and display the sub categories?
ie. For each new catagory there will exsist a sub-directory. Inside that sub-directory may exsist additional sub-direcoties.
When traversing or parsing for display you could recursively call a function to handle (display, list, etc.) the contents of the current directory.
|
 |
|
|
Topic  |
|