May 7, 201016 yr Yes I will be pounding questions onto the PHP forum now as I try to understand the theory behind the coding etc. I have been reading the W3C schools PHP tutorials, most of which has gone in. Now I want to use the "include()" function on my pages as I am doing a site which the menu will change. I have included the coding in the pages and then uploaded it to my server. Now the page loads but the menu doesn't appear..... Suggestions? Regards, Junior
May 7, 201016 yr This should go in each page instead of the menu markup:- <?php include ("menu.inc"); ?> You create a page called menu.inc and put it in the same folder/directory as the main pages. It only needs the menu code that you cut out of the main pages like:- <ul> <li>.........</li> <li>.........</li> </ul> no doctype, html tag, body tag, etc. Name each main page with .php extension and check that your host supports PHP. You won't see the result on your computer from local files unless you have a server like Apache included in WampServer2. You should see the menu online if your host supports PHP.
May 7, 201016 yr Author My host supports PHP I have run the test.php. .inc not a .php like the tutorial I was reading said? Regards, Junior Edit: I have got it working but now have another query. I was using the Nifty corners js script and had it working is there a way to get these two working together?
May 7, 201016 yr My host supports PHP I have run the test.php. .inc not a .php like the tutorial I was reading said? Regards, Junior You can include any file such as menu.html, menu.php, menu.inc, as Wickam said save the code you want to include eg <ul> <li>.........</li> <li>.........</li> </ul> I assume your menu code will be held in a div such as <div id="menu"> Then the whole code would be <div id="menu"> <?php include 'menu.html'; ?> </div>
May 7, 201016 yr I was using the Nifty corners js script and had it working is there a way to get these two working together? A PHP include just substitutes code from one page into another, so it can work with any code. You sometimes have to be careful to get the paths correct if you have files in different folders, so start by keeping them all in the same folder/directory until you feel confident. Using .inc for the "include" file just makes it easy to identify the "include" file(s) when you have lots of other php, html, txt files in the same folder.
Create an account or sign in to comment