Page 1 of 3

"You are here" navigation

Posted: Wed Jul 07, 2004 11:39 am
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!

Posted: Wed Jul 07, 2004 11:59 am
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..

Posted: Wed Jul 07, 2004 12:05 pm
by theperfectdrug
well maybe there is an easier way, like using one table in database instead of two...hm :roll:

Hey any ideas?

Posted: Wed Jul 07, 2004 12:10 pm
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...

Posted: Wed Jul 07, 2004 12:11 pm
by John Cartwright
$_SERVER["http_referer"] will tell you where you came from

Posted: Wed Jul 07, 2004 12:15 pm
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. :)

Posted: Wed Jul 07, 2004 12:19 pm
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.

Posted: Wed Jul 07, 2004 12:24 pm
by theperfectdrug
hm..cookies, i've read somewhere that using cookies is not the best solution for breadcrumb navigation.. :roll:

Posted: Wed Jul 07, 2004 12:26 pm
by pickle
Really? Any particular reason?

Posted: Wed Jul 07, 2004 12:27 pm
by theperfectdrug
disabled cookies in browser maybe? :roll:

Posted: Wed Jul 07, 2004 12:31 pm
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.

Posted: Wed Jul 07, 2004 12:36 pm
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:

Posted: Wed Jul 07, 2004 12:37 pm
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.

Posted: Wed Jul 07, 2004 12:41 pm
by feyd
we just talked about this: viewtopic.php?t=23238&highlight=structure :roll:

Posted: Wed Jul 07, 2004 12:43 pm
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: