Gast Posted April 15, 2006 Share Posted April 15, 2006 I have a simple page system for a content management system where you can make a page with the parent id of 0 (ie. a top level page), and then make other pages underneath using the parent page's ID as that page's parent id (if that make sense). This is what I mean:Page 1 (parent id: 0, id: 1)[blockquote]Page 2 (parent id: 1, id: 2)[/blockquote][blockquote]Page 3 (parent id: 1, id: 3)[/blockquote][blockquote]Page 4 (parent id: 1, id: 4)[/blockquote]Page 5 (parent id: 0, id: 5)Page 6 (parent id: 0, id: 6)[blockquote]Page 7 (parent id: 6, id: 7)[/blockquote][blockquote]Page 8 (parent id: 6, id: 8)[/blockquote][blockquote][blockquote]Page 9 (parent id: 8, id: 9)[/blockquote][/blockquote][blockquote]Page 10 (parent id: 6, id: 10)[/blockquote]Page 11 (parent id: 0, id: 11)Like that for example. Now each page is stored in the same table in the database. I can fetch all the results easily, by fetching all pages with the parent of 0 to display differently as they are top level pages, and then inside the while() loop used for that do another while() loop for each other page.However I don't want to do loads of loops inside each other as I dont want to limit the amount of levels a page can go down. Is there a way to just fetch all pages under the right parents in one go?TIANiall Quote Link to comment Share on other sites More sharing options...
Gast Posted April 16, 2006 Author Share Posted April 16, 2006 *bump* Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.