Jump to content

[SOLVED] loading info to place inside div...


Drags111

Recommended Posts

Hello there! im making my first website, and i have a quick question. What I want to do is have a php script load the info for a navigation bar that i have and i want the php to display the navigation bar inside the page. Like for instance, i have a file called navbarinfo.whatever and the script loads that and displays the nav bar using the info found there. This way i wont have to change the nav bar on every html page i have when i add a new section. I'm positive this is possible, how do i do it? Much thanks!

-Justin

Link to comment
https://forums.phpfreaks.com/topic/158491-solved-loading-info-to-place-inside-div/
Share on other sites

ok so i tried it out and i made a php file called mainnav.php with this code:

	<h1 class="mnh"> <a href="index.html" class="mnlink"><b>HOME</b></a>  </h1>
<div id="headervr"></div>
<h1 class="mnh"> <a href="/comedy/index.html" class="mnlink"><b>COMEDY</b></a>  </h1>
<div id="headervr"></div>

 

and in the section where i belongs i put

				<div id="headerdiv">
				<h1 class="headerh"> <b>jdubya</b> </h1>
				<h1 class="com"> .com </h1>
				<div id="headerhr"> </div>
				<?php include("mainnav.php"); ?>
			</div>

Its working, however. It just doesnt show up. Can anyone see what i'm doing wrong?

 

 

Place mainnav.php in your sites root folder (where you upload your sites content too). Now use

 

include($_SERVER['DOCUMENT_ROOT']."/mainnav.php");

 

PHP will now always include mainnav.php from your sites root folder no matter where its included from.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.