Forum Moderators: coopster

Message Too Old, No Replies

PHP Navigation

php navigation

         

PumpkinHead

1:43 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Hi,

I have the following PHP code that I use for navigation within my website.

<?php
If ($page==0) { include("page1.php");}
If ($page==1) { include"page2.php");}
?>

And my links are as follows :

<a href="index.php?page=0"> News </a>
<a href="index.php?page=1"> Links </a>

Could someone please tell me how to change this code so that I can use text values (I.e If ($page==news)) as I can't seem to get this to work.

Another couple of questions..

* Is this the standard way of doing website navigation?
* Will Google understand php navigation or will it think I only have one page?

Thanks again.

Knowles

1:55 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



if ($page=="news") {blah

That should allow you to use the actuall name instead of the number. When ever you use works you have to put them in quotes either single or double depending on your coding style. I think there are some actually some valid reasons for useing certin ones at certin times but for what you are doing double or single will be fine.

The great thing about PHP and writing your own code there is no true standard way. I have designed sites this way and done it other ways. it all depends on what your doing and what you want to achive.

I have not had alot of issues with google grabing the names when they are small. There has been lots of debates on issues with varibles in urls and if I remember correctly you are ok if its not a whole slew and it seems to have problems with sessions IDs due to the length of them. It will think you have more than one page however it doesnt view it as one page since the content should be different on each page.

PumpkinHead

2:02 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Great thanks :)

So I take it the links will have to be as follows...

<a href="index.php?page='news'"> News </a>

Knowles

2:09 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



No you dont need quotes there just in the if statement. I am not real sure what would happen if you put them in the link text like that. I am sure I have done it at some point but I think it would result in an error.

ergophobe

4:10 pm on Mar 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



To answer your other question, Google doesn't care at this point whether your page is

site.com/index.php?page=news

or

site.com/news/

Your visitors, however, might care and you might too. The second version has some major advantages

1. easier for people to say over the phone
2. easier to remember
3. won't change when technology changes
4. recommended by W3C

Search Google and WebmasterWorld (using Google) on "clean URLs" and "search engine friendly URLS" and "human readable URLs" and all of above using URI instead. Also look for Tim Berners-Lee article on "Cool URIs Don't Change"

Tom