Printing navigation menu's HTML to the screen

hey guys,

I have a very nice navigation menu on the side of one of my pages, but it is quite long and I don’t want to have this code appear on every one of my pages as being typed out manually. is it a common thing in the PHP world to store code like what I have below, inside a database and simply use PRINT() or ECHO() to throw it to the screen when someone requests a page? or rather, CAN I do that to make things easy on myself? here’s a portion of the code that I currently have:

<ul>		
<li> <a href="#Software">Software</a>		
	<ul>	
	<li> <a href="#DesktopApplications">Desktop Applications</a>	
		<ul>
		<li><a href="#">Access</a></li>
		<li><a href="#">Excel</a></li>
		</ul>
	</li>	
	<li><a href="#">Web Applications</a>	
		<ul>
		<li><a href="#">PHP</a></li>
		<li class="#"><a href="#">Python</a></li>
		</ul>
	</li>	
	</ul>	
</li>		
</ul>

the menu will be a lot longer that this, so I’m trying to make things much easier on myself so I don’t get lost and confused when reading code. thanks.

You would store category parent/child information - id, parent id, and name, in one database table and store the page information - category id, title, description, content, and any other relevant page data in other normalized database table(s) and dynamically produce and output the navigation and dynamically produce and output the requested page, using php code, so that you are not manually creating, maintaining navigation and pages.

what about using, say, a header and footer PHP file and include that in all of my static pages? someone else mentioned that I could do that as well. that would not require any database dynamics. is that OK to do in a situation like this?

Sponsor our Newsletter | Privacy Policy | Terms of Service