Re: navigation...

From: Date: Wed, 03 Oct 2001 15:43:29 +0000
Subject: Re: navigation...
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-12989@lists.php.net to get a copy of this message
Deco <rbr@netcabo.pt> wrote in message news:20011001214825.22076.qmail@pb1.pair.com... > > My will is to return the areas in some cascade order... I can do it > recursively, but it generates too many queries. I was wondering how i could > do this with only one query to the database. > > Here's the structure i have so far: > AREAS (area_id INT; parent_id INT; root_id(??) INT; description > VARCHAR(60)); > Hello, I've come across this type of thing for link categories/subcategories. Heres how I solved it: Table Structure: cat_id INT; parent_id INT; desc VARCHAR(255); sort_id INT; Example rows: 1 0 Computers 1 2 1 Hardware 2 3 2 Modems 3 4 1 Software 4 Take a look at the sort_id field. Now, to get all the categories & subcategories I just sort all records by sort_id ASC. This however requires severe maintenance when adding/deleting records. Hope this helped. Charade.

« previous php.db (#12989) next »