Jump to content


Photo

Page/category system


  • Please log in to reply
1 reply to this topic

#1 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 15 April 2006 - 01:54 PM

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?

TIA

Niall
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application

#2 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 16 April 2006 - 09:09 PM

*bump*
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users