Self-Refering Categories - print all ??

Results 1 to 2 of 2

Thread: Self-Refering Categories - print all ??

  1. #1
    Join Date
    Dec 1969

    Default Self-Refering Categories - print all ??

    Hi, i have a database table for categories in the following form<BR><BR>---------------------------------<BR>ID Name Parent_ID<BR>---------------------------------<BR>1 Sports 0<BR>2 Camping 0<BR>3 Football 1<BR>4 Hockey 1<BR>5 Ice Skates 4<BR>6 Sticks 4<BR>7 Helmets 3<BR>8 Tents 2<BR><BR>which basically in theory builds an endless hierachy of categorys ( pretty simple to understand ). But, how can i print this whole hierachy of categories to the screen all at once, so it outputs :<BR><BR>-Sports<BR>---Football<BR>-----Helmets<BR>---Hockey<BR>-----Ice Skates<BR>-----Sticks<BR>-Camping<BR>---Tents<BR><BR>???? obvoisuly it involves a fair few while/for loops, but i cant seem to figure out how to make it work with an infinate number of category levels. could anyone give me some tips, examples of code, whatever you can ? thanks, adam

  2. #2
    django reinhardt Guest

    Default recursion<BR><BR>btw - xml is a beautiful way to represent hierarchies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts