Re: Category Listing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 21 Sep 2003, Paul B. [pbcomm, aka WPD] wrote:

> Hi, i'm working on the site that involves a lot ot categories and subs there
> of ... The way i have things now is that the structure goes one sub deep ...
>
> Ex:
>     PHP -> Database
>     PHP -> Books
>
>     in the DB it looks like:
>         id 1 name PHP parent 0
>         id 2 name Database parent 1
>
> this way its easy to show dinamicaly where the user is (PHP: Database) by
> prividing
> index.php?dir=1&sub=1.
> What i want to do, is go 3 or 4 subs deep. I just wanted to get an idea on
> the best posible way of doing this.

 index.php?dir=2

 Then select * from DB where id=2
 that gives you

 2  Database    1

 If parentid!=0
    select * from DB where id=parentid (1 in this case)
    push $name onto an array (database is now array index 0)

 Then you'll have

 1  PHP         0

 Know you know you are at the top.
    push $name onto an array (PHP is now array index 1)

 Now just pop them off the array (PHP -> Database -> end of array)

Beckman
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux