Easy-peasy PHP 2 : Comments
July 11, 2005
Comments
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
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
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
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.
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”);
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?
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



You can use this
feed to keep up with the comments made on this article.