Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL dB and Website Navigation 1

Status
Not open for further replies.

NigeW

Programmer
Jun 10, 2002
134
NZ
Hi there

I am new to PHP programming and am hoping someone can point me in the right direction - not really looking to get a packaged answer, just a shove in the right direction.

My problem :

I have a pet project of building a CMS system using PHP, MySQL and one of the free WYSIWYG editors.

Maybe I am starting in the wrong place but I wanted to get the front end working fine prior to attacking the back end.

I am using as my basis for building the site and cannot figure out how to extract the data from the database to build the 2 level (needs to be 'n' level really) site navigation

My table structure is (truncated for simplicity):

Field
=====
Id Primary Key, auto increment
Name Name of Page
ParentId The parent Id the page is linked to


I have a "God" entry in the table (with an Id of 1) so that the first level navigation items all have the ParentId value of 1. Then any sub items point back to the relative table entry.

So to write a function, etc to dynamically build this is where I am stuck.

I thought about a resursive type function, then maybe using multi demensional arrays.

Help please, my head is spinning . . .

Thanks

Nigel Wilson
Christchurch Web Design
 
You are building something here that is like a tree structure.
There are several articles about tree structures, one I find very interesting which introduces the concept of modified preorder tree traversal. That's probably not what you need, but the concepts discussed will help you:
 
Hi DRJ478

Thanks for the link to Sitepoint - one of their books I think deals with building this exact problem I've got.

Star to you

Nigel

Nigel Wilson
Christchurch Web Design
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top