Hi everyone. I've got to build a website with over 50 pages on it and I'll be using a css3 mega menu. I know very little about php and have been told using an include for the menu and making the pages php pages I could easily modify the menu and it would update all the pages at one time. My question is...if this is correct then how do I make the include for the menu? Thanks in advance Sveta
You will need to make a separate file (we'll called it menu.php), which will hold the menu stuff. All you need to do then is on every page you make, put this line of PHP where you want the menu to show. <?php include("menu.php"); ?> PHP: Then, within menu.php you'd put all the HTML for the menu and everytime you update that file, it will automatically update the menu on all the pages where you have put the PHP "include" tag. Understand?
Thanks so much for your reply. Ok. I make a php page and call it menu.php. I then add the mega menu on that php page. I then make all the other pages on the site php pages. I then put menu.php include on the other pages where I want the menu located on the page. Correct, or am I still lacking something? Sveta
I made a php page and saved it as menu.php and then put the menu on that page. I made another php page and tried these 3 things on the new php page where I want the menu but it still doesn't work.(menu doesn't show up on the page) menu.php <?php include('incl/menu.php'); ?> <?php include 'menu.php'; ?> What am I doing wrong. Thanks again
Guessing you have the files like so: - index.php - page1.php - page2.php - menu.php Code (markup): In index.php, you will just need to have just one include tag. <?php include("menu.php"); ?> PHP:
Apart from menu.php what other files have you created. If you want to include the menu, then these files have to be .php files as well. There are ways to do this on HTML files, but since you said you are a beginner, lets not try that just yet. Also, what do you see when you view the menu.php from your browser. Do you see the menu or not. <?php include('incl/menu.php'); ?> have you put the menu.php on the folder "incl"?