mynameisham Posted January 22, 2008 Share Posted January 22, 2008 <?php $page="main"; ?> <div id="page" align="center"> <div id="header"> <img src="images/header.jpg" border="0" usemap="#Map" /> <map name="Map"> <area shape="rect" coords="0,0,800,93" href="index.php?page=main"> <area shape="rect" coords="57,113,203,161" href="index.php?page=gallery"> <area shape="rect" coords="214,112,419,155" href="index.php?page=reel"> <area shape="rect" coords="428,116,580,160" href="index.php?page=resume"> <area shape="rect" coords="593,112,746,152" href="index.php?page=contact"> </map> </div> <div id="middle"><br /><br /> <div id="body"> <?php @ require_once ("$page.htm"); ?> </div> </div> <div id="footer" align="left"> </div> </div> This is the code I'm using to attempt to make the links in the header open a different page with include. At first the code would just stop rendering right before the require tag, but after I added in the first php code to define the variable $page as main at first, it would at least render the entire page correctly. Now, however none of the links work. They change the address in the address bar to index.php?page=gallery, but the div never changes to the gallery page. Any ideas on what I might be doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/87281-need-help-linking-in-a-template-with-a-variable-and-include/ Share on other sites More sharing options...
mynameisham Posted January 22, 2008 Author Share Posted January 22, 2008 Sorry for the double post, but I meant to include that the links have never worked. The only way the php displays the site I want it to is if I hardcode a value for the variable into the site somewhere, which then takes away from the modular nature I'm going for. I took out the hardcoded $page="main" tag, because I knew that was just keeping my links from working, but it still didn't fix anything. And once my links are working, how do I give the $page variable a default value of "main" so that it will load the main site on the first visit? I know the reason the links don't work right is because the code stops when it's looking for a value for $page on that initial load, and it returns a value of nothing. Thus, the html translation ends there and the code my links relied on to function isn't even on the page. But if I hardcode a value into the site, when the links reopon index.php, the value of $page is overwritten by the hardcode. I'm at a catch 22 it seems! Quote Link to comment https://forums.phpfreaks.com/topic/87281-need-help-linking-in-a-template-with-a-variable-and-include/#findComment-446462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.