Re: Category Listing
| From: | Peter Beckman | Date: | Mon, 22 Sep 2003 07:07:51 +0000 |
| Subject: | Re: Category Listing | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-30615@lists.php.net to get a copy of this message | ||
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/
---------------------------------------------------------------------------