Thread: categorie tree

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    1
    Rep Power
    0
    I'm making a admin for categories in an e-commerce shop.

    I want to show the categories like this (and then in a table)

    TOP
    |--+ clothes
    | |--+ tshirt
    | |--+ trousers
    |
    |--+ toys
    | |--+ lego
    | | |--+ collector items
    | | |--+ star wars
    | |
    | |--+ barbies
    |
    |--+ food

    The table looks like:

    table categories:

    id --> category id
    parent_id --> parent category id
    name --> name category
    description --> description category

    Do u have any ideas how I can do this??

    Thanks,

    Anita
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    Simple threaded display suggestion with recusive function:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

    $strlevel="";

    function DisplayThread($ParentID,$Level)
    {
    if($level>=strlen($strlevel)) $strlevel = $strlevel."0";

    //get messages with parent = ParentID

    for(**each message with parent $ParentID**)
    {
    if(**more message with parent $ParentID to do after this one**) $next=true;
    else $next=false;

    if($next) $strlevel[$level]='1';
    else $strlevel[$level]='0';

    for($i=0;$i<$level;$i++){
    if($strlevel[$i]=='1') **display down | **
    else **display empty **
    }

    if($next) **display t split |-**
    else **display r split |_**

    **display the message + to nextline **

    DisplayThread($newparentID,$Level+1); //display message children
    }
    }
    [/code]

    here u go


    ------------------
    Greetings lewi

Similar Threads

  1. deallocation of a tree
    By kemalican in forum C Programming
    Replies: 1
    Last Post: February 1st, 2004, 11:29 PM
  2. delete from binay tree
    By tony825 in forum Java Help
    Replies: 0
    Last Post: December 12th, 2003, 02:41 PM
  3. binary search tree removal
    By tjawed in forum C Programming
    Replies: 4
    Last Post: December 7th, 2003, 01:12 PM
  4. binary tree insertion help
    By kashifkhan in forum C Programming
    Replies: 1
    Last Post: November 9th, 2003, 04:29 PM
  5. storing strings in tree
    By SHiBBi3 in forum C Programming
    Replies: 2
    Last Post: October 27th, 2003, 09:17 PM

IMN logo majestic logo threadwatch logo seochat tools logo