SmokingMan Posted April 11, 2006 Share Posted April 11, 2006 Let me preface this by stating I know nothing about PHP. I have a navigation menu I want to include in every page on my site. Instead of writing the code in every page, I was told I could use PHP to call the file from the .html document I want the menu to be in. So here's the problem.I have the calling document "index.html" calling the seperate menu file "navmenu.html". In "index.html I have the code: <div class="nav"><?php require("navmenu.html"); ?></div> Both files are in the same directory, but the menu does not show up in the "index.html" document. The hosting server does support PHP 5. What am I missing here, why doesn't the menu show up? Link to comment Share on other sites More sharing options...
calvin182 Posted April 11, 2006 Share Posted April 11, 2006 Make sure any page that uses php in it has a .php extention. Your code looks about right though. Link to comment Share on other sites More sharing options...
Selacius Posted April 11, 2006 Share Posted April 11, 2006 Use include ("navemenu.html") instead. Link to comment Share on other sites More sharing options...
Little Goat Posted April 11, 2006 Share Posted April 11, 2006 (edited) maybe use php include?LGEdit: Oh, selacius types faster than me. Edited April 11, 2006 by Little Goat Link to comment Share on other sites More sharing options...
SmokingMan Posted April 13, 2006 Author Share Posted April 13, 2006 Make sure any page that uses php in it has a .php extention. Your code looks about right though. So this would rename my index.html file to index.php? Would that still enable people to access my site? And would that mean all pages would need the .php extension since I want this menu on every page?Use include ("navmenu.html") instead.Would I use this format "<!--#include file="navmenu.html" -->" along with an ".htaccess" file? I'm not clear on what an ".htaccess" file is and where it goes though. I just remember reading that when I was looking into how to do this.I told you I'm out of my league on this. I'm comfortable with CSS & XHTML, but not PHP...yet. Link to comment Share on other sites More sharing options...
Selacius Posted April 13, 2006 Share Posted April 13, 2006 Your index.html file will need to be a *.php file, your server would need to be configured to allow php as well. The actual code would be:<? include ("navmenu.html"); ?> Link to comment Share on other sites More sharing options...
calvin182 Posted April 13, 2006 Share Posted April 13, 2006 correction, the actual code would be <?php include ("navmenu.html"); ?> the .htacess file has nothing to do with this, thats controlls access to bots, folders aswell as numerous other functions. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 19, 2006 Share Posted April 19, 2006 You could also just configure the server to send html files to the PHP engine, but that would slow down response times slightly for html pages. But you wouldn't have to rename anything.You can also use:include()include_once()require()require_once()Depending on what your requirements are (no pun intended). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now