This is the first post I've made on these forums and I was hoping that someone here could tell me why my code just doesn't work. I'm a complete newbie to PHP, so I'm really not sure...
Here is the code:
<?php $den = ""; if ($den == "") { include "index.htm"; } else { include "$page.htm"; } ?>
Now this handy little code is meant to be a page handler. It is located in my home page (Code.php) in a table Header, where I want my content to load.
My content is arranged into .htm pages and my problem is that although the script runs the initial content (index.htm) correctly, it will not load any other pages of content, regardless of which link I click on my Navigation Bar which is loaded in Code.php.
The reason I want this script is so that I click on any link on my nav bar and it only has to reload the content (Thus I only need to write out my nav bar once, in Code.php)
Now as far as I understand, my script declares a variable ($den) and assigns it an empty value, which means it will load index.htm as content. This part seems to work fine. It then declares an else statement that loads the variable $page.htm if $den is anything apart from blank. This is where something goes wrong.
The links on my nav bar are all relative and lead to:
Code.php?den=pagename
and as far as I know, that should load pagename (.htm as stated in the variable $page, I shouldn't need to write .htm again here) into the variable $den of Code.php.
Only it doesn't :mad:
Can anyone help me? and did I make my problem clear enough? 😕