Forum Moderators: phranque

Message Too Old, No Replies

How do make a php nav bar?

         

naitsirhc26

11:49 pm on Jun 26, 2006 (gmt 0)

10+ Year Member



I was wondering if anybody knew how to do a php navigation bar. I need to learn how to update the one nav bar php page, which in turn will update all of the other pages nav bars.

naitsirhc26

12:09 am on Jun 27, 2006 (gmt 0)

10+ Year Member



I can use the include tag, but I need to know how to set up the navbar.php file. Do I have to write it in php, or can I write it like this:

<?
<div>
?>

Do I have to write the navbar.php file completely in php? How would I write that file?

naitsirhc26

12:38 am on Jun 27, 2006 (gmt 0)

10+ Year Member



Okay so this is what my markup looks like:

file.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php include('navbar.php');?>
</body>
</html>

And this is what my navbar.php file looks like.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Hello my name is Christian
</body>
</html>

Please tell me what I did wrong becuase it isn't working.

coopster

12:52 am on Jun 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You are including one full <html> file within another. The navbar.php normally would only be something like you stated in your second post, just some partial html code:

navbar.php

<div> 
<ul>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
</ul>
</div>

Also, your main file is ending in .html. That is fine as long as you are processing .html files as PHP.

naitsirhc26

1:10 am on Jun 27, 2006 (gmt 0)

10+ Year Member



Okay, it still isn't working. Could you please write both codes for me. I can do the rest. Please title them, and maybe then I will get it.

naitsirhc26

2:03 am on Jun 27, 2006 (gmt 0)

10+ Year Member



Anybody who could do this would be really helpful.

eelixduppy

2:13 am on Jun 27, 2006 (gmt 0)



It would be exactly as coopster stated:

nav.html


<div>
<ul>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
</ul>
</div>

page.php //must be parsed as php in order for the include to work


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include('nav.html');?>
</body>
</html>

Good luck!

naitsirhc26

3:03 am on Jun 27, 2006 (gmt 0)

10+ Year Member



I get it now. Thank you so much.