Anchal Jain Anchal Jain - 1 year ago 38
HTML Question

One menu bar for multiple page in html

I am creating a html page for the school project course registration system I am creating a home page with dropdown menu bar I want it the same menu bar is displayed on each page. I trying to understand with the help of templates but I can't understand how can I use it after that I searched use php line to add in html page
but I am confused is it I need to edit the whole html code in php code so help me to figure out this problem because I don't know how to code in php...

here is the code
enter image description here

and the page looks likeenter image description here


use php include and require they are used to include and load snippets of codes in any section of your html page, in your case just put your navbar code into a seperate php file and then include it at the top of any page you want to have it

<?php include('navbar.php') ?>
//rest of your page

include means that the page will still load if for some reason the navbar.php file dosen't load

But if you want the page not to load without loading the navbar, then use require. this will be ideal if you make a database connection in your navbar file (ideally you shouldn't do that though). but it's just there if you require some assets or file to load completely before loading the main page

<?php require('navbar.php') ?>

check this out