Help created a dynamic php menu via includes.

Posted on 2007-07-25
Last Modified: 2013-12-12
I have created a php real estate application, and i have the menu done in blocks with each block a seperate page and placed in the menu via includes.  What i'd like to be able to do is have a page in the admin section that would allow the user to turn off/on blocks using a form.  Is there any way to dynamically create a list of the available modules by the script getting the list from the includes/modules folder and then displaying the available ones in the admin section and also to display the active ones on the menu.
Also if possible there are some modules that should be displayed on the menu and other on the main page is there any way to seperate them and have the admin section decide where to place them.
Using php and mysql
Thanks in advance for any help.
Question by:Karen Liddy
    LVL 4

    Expert Comment

    Yes, all this is a possible.

    If I were to do something like this I would create a table in the database with all the modules and the location to some folder.

    Table layout would look like this
    module_id - int auto increment
    module_name - varchar(??)
    module_location - varchar(??)
    menubar_location - varchar(??) or int(1) if you just have 2 sections they could go example - admin, menu

    Then I would create another table with user id and what modules they want.
    module_id int,
    user_id int,
    primary key(module_id,user_id)

    In order to figure out where things do you reference the database and create dynamicly from it.

    In the admin section let users add and delete modules on the fly.

    I dont know what other people would recommend but this is how I would do it.

    Author Comment

    by:Karen Liddy
    thank you for that, i did actually start to do it similarly but how do i get the script to show the pages, i have tried to put the path with the include statement and without, obviously that didn't work.  it's just that i've never tried anything like this i usually just work with getting data from mysql and listing it.

    also how can i place them on different parts of the page depending on what they choose in the admin. for example, the mods payments, registration and news are active, one customer might want the news on the menu bar where another might want it on the main page, obviously i would have placemarkers so that the mods only appear in a certain place on the main page, but how do i make them move from the choice in the admin.

    thanks for your help
    LVL 4

    Expert Comment

    all you have to do to get this to work is to pull the information from the database based on there user_id

    second, create a numbering system where you have spots 1 - 10 that people can chose dynamically. when they choose where to put something add a record to the database.

    Author Comment

    by:Karen Liddy
    thanks again for your answer.  i get how to do the database bit but what i don't know how to do now is: each modules first page is a .php file, and the file structure is :  /includes/modules/news/news_box.php, in the database how can i put in an include command or how do i get the menu to show the correct php file

    I hope that i'm explaining myself properly.

    LVL 4

    Accepted Solution

    just pull the modules that a user wants to use from the database and then use php to pull it in with an include statement.

    while($row = mysql_fetch_array($module)) {

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now