html - PHP Header Include (nav bar) not showing up -


clarification: being i've never used php, unclear how format php file, when include in index, header(nav bar) show up. no posts explained why had change index.html index.php make work. , again, being haven't used php, under impression changing extension meant have convert html code php commands. trying avoid having change whole code around. that's confusion was.

i going delete question once got figured out. again, i'm sure i'm not person may run while making first website.

solution. save nav code in html language php extension (header.php). change index/home file .html .php extension (don't have modify code. accepts include prompt). then, include header.php in index.php. same goes footer. everyone.

*original post: through post, told easier use nav/footer on multiple pages using php.

i created file , tried including , not displaying. i'm not sure doing wrong.

there css in nav bar well, need import css file in php file? or index.html file automatically attach included (php) file.

php code:

<?php echo '<nav>     <div>         <a href="/">             <div id="logo"><img src="/images/7servicelogoblue2.png" alt="home"/></div>             <div id="headtag"><img src="/images/title.png" alt="home"/></div>             <div id="tagline"><img src="/images/tag_line.png" alt="home"/></div>         </a>     </div>     <div>          <a href="/" class="here">home</a>         <a href="/about.html" >about</a>               <a href="/services.html" >services</a>                   <a href="/pricing.html" >pricing</a>             <a href="/contact.html" >contact us</a>         <input id="srchbar" type="search" placeholder="search">     </div> </nav>'; ?> 

html code (include):

<body> <?php include '/header.php';?>     ....other code.... </body> 

if there's problem php file, if i'm missing something, can show explain please?

no need add <?php ?> code in header file keep :

  1. create new file named header.php , add code it

    <nav> <div>     <a href="/">         <div id="logo"><img src="/images/7servicelogoblue2.png" alt="home"/></div>         <div id="headtag"><img src="/images/title.png" alt="home"/></div>         <div id="tagline"><img src="/images/tag_line.png" alt="home"/></div>     </a> </div> <div>      <a href="/" class="here">home</a>     <a href="/about.html" >about</a>           <a href="/services.html" >services</a>               <a href="/pricing.html" >pricing</a>         <a href="/contact.html" >contact us</a>     <input id="srchbar" type="search" placeholder="search"> </div> 

  2. include header.php anywhere want


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -