Question:
How do I Create a Dynamic Menu using PHP?
Master 4 Science
2009-07-07 21:11:37 UTC
I trying to design a "dynamic drop menu" for a website, using PHP.

The Code needs to work so that code for the menu is only written once.
Each 'html' page uses the menu refer-ed in PHP file.

I not sure how to do this, but I am assume that I will also need some CSS or Javascript to create the "dynamic drop menu".

Could someone possibly tell me how to go about this?
Provide some sample code or some links?
Three answers:
anonymous
2009-07-11 00:05:52 UTC
The dynamic part of the menu, your don't need php for. You would use javascript and/or css.



To make it so that you only have to write the code once, you can use the include() function.



Make your dynamic menu in one page.



Then take all the code of that menu and cut and paste it in a different page called menu.php



Then anywhere you want to have that code you can use include('menu.php'); and that would include all the code of menu.php where the include funtion is.





You really only need css to make a drop down menu, here's a page that shows you how:



http://www.evolt.org/article/headline/17/52030/index.html



Hope that helped
maebry
2016-11-08 13:07:58 UTC
Use own homestead page to produce HTML/CSS/Javascript of drop down menu. fairly codes would be just about same different than links and contact of links. Use own homestead page variables for links. in this sort, each and every web site will render same menu, yet with distinctive links count on own homestead page variables. And own homestead page variables would be assorted reckoning on the situation of webpages. Create this own homestead page code in separate document. And import this document in each and every HTML and/or own homestead page making use of "include_once" or "require_once"
anonymous
2009-07-07 21:31:39 UTC
you dont use php for that... you use javascript...



specifically, you download a free one from hotscripts.com, change it to what you need..



you have a file called head.php, another called menu.php, and another called footer.php...



in each "body page" you create, use includes to pull those pages into it... you can create thousands of pages, and use includes of those specific pages, then basically you only change that info once for it to show universally....





include "header.php";

(includes all meta data, title, keywords,



include "menu.php";

(the guts of your menu)



your info goes here for the page...



include "footer.php";

copyright, etc etc







get it?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...