Digital Web Magazine

The web professional's online magazine of choice.

Easy-peasy PHP 2 : Comments

By Jim Amos, Mike Papageorge

July 11, 2005

Comments

Douglas Clifton

July 12, 2005 7:40 AM

I’m glad to see the authors demonstrating the switch/case control structure for conditional includes. So much cleaner and easier to code and understand than a pile of nested if/elseif/else statements. Good work! ~d

tim0fee

August 14, 2005 5:09 AM

Great! Thanks so much for all yout time & effort. I was following a link to the old version of this tutorial for a while and things wern’t going right. Now it’s all OK – brilliant!

Thanks again Jim and Mike and all other contributors.

tim0fee

halo

September 6, 2005 3:02 AM

Thanks for the great tut!

...though I notice that if I place the ‘navigation.php’ include code anywhere other than where it is in your (more advanced) downloadable sample files – the ‘currentpage’ CSS indicator stops working! Weird…

Anyone know why this might be or how I could alter the PHP code to allow me to place the ‘navigation’ anywhere I choose whilst retaining the ‘currentpage’ state?

Ta,

halo

John Faulds

September 18, 2005 4:59 PM

I’m no expert with PHP, but I found you can even do away with a switch statement by doing where $path is the path to the includes folder + the name passed in through the querystring. I have used a switch statement cos I’ve got different include folders, but if all your includes were in the same location, it seems like you wouldn’t need a switch statement.

John Faulds

September 18, 2005 5:02 PM

Sorry, having to post twice cos the previous version stripped out some code even though it looked OK in the preview. Between doing and where, it should say include (”$path.inc”);

Chance

October 26, 2005 1:25 PM

Ok … I adapted the code a bit and got it to work. I click and fetches the id and it displays what I want it to display.

My question is how I can get it to display to a particular cell in a table.

I’ve attempted to do this by various means without success. I can get it to display at the top of the page before the table begins or I can get it to display in the top cell but it pushes the contents of that cell down in order to do so.

Any advice?

Nate

November 2, 2005 7:21 AM

One important note with the includes. It is much more secure to define a site root via PHP define, and then use that in the include statements instead of $_SERVER[ ‘DOCUMENT_ROOT’ ].

So you would define(‘SITE_ROOT’, $_SERVER[ ‘DOCUMENT_ROOT’]) and then use SITE_ROOT in place of the document roots.

Very good for beginner PHP...

Peace

Sorry, comments are closed.

Media Temple

flash-template.com

Advertise with us

Publishing services provided by Blue Flavor

Photos provided courtesy of iStockPhoto.com

Publication managed with the help of Basecamp

Newsletter powered by Campaign Monitor

Content system developed by visicswire

Code managed with help from Beanstalk