"You are here" navigation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

theperfectdrug
Forum Newbie
Posts: 24
Joined: Tue May 25, 2004 10:15 am

"You are here" navigation

Post by theperfectdrug »

Hi!
Can anyone suggest what is the best way to make breadcrumb navigation using php & mysql? (I mean what would be the best structure for tables in database, it will be also helpful if someone will provide a lil' example of php code. :))

Thanks
Any help would be appreciated!
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Yea really. I am working on this same problem myself.

I have some ideas.

Making 2 tables. One with URLID, URL, AND URLINFO, the other with PARENTID and URLID. link the URLID with primay/foriegn keys,t hen whenver a URLID Is called , have it also call the parent URLID's with use of PARENTID...

...I havn't done much else yet.. lol..
theperfectdrug
Forum Newbie
Posts: 24
Joined: Tue May 25, 2004 10:15 am

Post by theperfectdrug »

well maybe there is an easier way, like using one table in database instead of two...hm :roll:

Hey any ideas?
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

yea sure i like 1 table better then 2 lol.


So my idea was that when the page loads, the php will check and see what the filename of the page is say TEST.php, then it will SELECT all from DB where URL= Test.PHP, then output the information along with it.

My only problem is, how will we track which links go before it...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

$_SERVER["http_referer"] will tell you where you came from
theperfectdrug
Forum Newbie
Posts: 24
Joined: Tue May 25, 2004 10:15 am

Post by theperfectdrug »

yea sure i like 1 table better then 2 lol.
same here. :lol:

well I'm not quite sure that your table structure is the best around, let's wait and see maybe someone will give us a little tip or example on this. :roll:

In my opinion table structure is the main problem...or maybe not. :)
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Phenom wrote:$_SERVER["http_referer"] will tell you where you came from
But that working successfully is dependant on the browser, and only shows the previous page, not a trail of pages.

My suggestion would be to use a cookie. When each page is loaded, or when a new directory is entered, add it to the cookie. Then, have a script that breaks apart that cookie and uses it to create a breadcrumb trail.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
theperfectdrug
Forum Newbie
Posts: 24
Joined: Tue May 25, 2004 10:15 am

Post by theperfectdrug »

hm..cookies, i've read somewhere that using cookies is not the best solution for breadcrumb navigation.. :roll:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Really? Any particular reason?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
theperfectdrug
Forum Newbie
Posts: 24
Joined: Tue May 25, 2004 10:15 am

Post by theperfectdrug »

disabled cookies in browser maybe? :roll:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Hmm, good point.

Another option is to actually have the files in a breadcrumb-type directory structure, then just parse the current working directory ([php_man]getcwd[/php_man]()) to get the breadcrumb trail.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
theperfectdrug
Forum Newbie
Posts: 24
Joined: Tue May 25, 2004 10:15 am

Post by theperfectdrug »

Another option is to actually have the files in a breadcrumb-type directory structure, then just parse the current working directory (getcwd()) to get the breadcrumb trail.
hm...maybe someone will post "database method" of breadcrumbs... :roll:
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

that sounds like an interesyting idea.. just break em up into folders, then make the folders linked breadcrumb..

Ummm, echo basename($_SERVER['PHP_SELF']); is a good way to have the php see what file it currently is displaying.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

we just talked about this: viewtopic.php?t=23238&highlight=structure :roll:
theperfectdrug
Forum Newbie
Posts: 24
Joined: Tue May 25, 2004 10:15 am

Post by theperfectdrug »

Ummm, echo basename($_SERVER['PHP_SELF']); is a good way to have the php see what file it currently is displaying.
after reading this article, I think that database way is the best...
http://www.sitepoint.com/article/hierar ... a-database

but good table structure is a main problem for me... :roll:
Post Reply