Do you have a working sample of the javascript dynamic menu with PHP/MySQL?
Return to Recent Questions
Q:
I want to create the javascript dynamic menu on my website using PHP/MySQL. I have found some info on
it in your Support section, but have problems to understand and
wonder if you have additional info or a working sample of the javascript dynamic menu with PHP / MySQL.
A:
Info about generating javascript dynamic menu (menu items )from a database, please, see:
http://dhtml-menu.com/menu/generate-menu-from-database-xml-php-asp-vb-support.html
The content of .php file depends on your database structure.
See the example of .php file:
<?php
// The example for PHP/MySQL.
// MySQL database has the table "menuTable" that contains data for javascript dynamic menu items.
// The table has the following fields:
// 1. "text" - item text
// 2. "link" - item link
// 3. "icon1" - item icon (normal state)
// 4. "icon2" - item icon (mouseover state)
function getMenuItems()
{
$jsItems = '';
// Select all records from table "menuTable"
$allItems = mysql_query('SELECT * FROM menuTable;');
// Extract items data from database and build Javascript code for menuItems
while ($itemData=mysql_fetch_array($allItems))
{
$jsItems .= '["'.$itemData['text'].'", "'.$itemData['link'].'", "'.$itemData['icon1'].'", "'.$itemData['icon2'].'"],';
}
// Return Javascript code
return $jsItems;
}
?>
<script>
var menuParam1 = value1;
var menuParam2 = value2;
var menuParam2 = value2;
...
var menuItems = [
<?php
// Write Javascript code for menu items
echo getMenuItems();
?>
];
</script>
Return to Recent Questions
Related:
- March 21, 2009 - How can we increase the width of the vista style buttons of javascript dynamic menu?
- Apr 07, 2009 - I want to get my text within a single javascript dynamic menu item to be on a two lines...
- Apr 25, 2009 - The javascript dynamic menu looks differently in IE 6 and Firefox...
- Apr 25, 2009 - How to work with drop down menu web and submenus in JSP?
- Apr 26, 2009 - My css menu example don't work with a popup...
- May 09, 2009 - I am unable to see any separators when working with javascript menu dynamique...
- May 12, 2009 - Is there a way to set a parameter such that when a javascript dynamic menu Item is CLICKED...
- May 29, 2009 - Will this menu popup work for us, as we use IFrames and Frameset?
- May 29, 2009 - Does javascript dynamic menu have support for Chinese or other Unicode characters?
- May 30, 2009 - Can you create/destroy drop down menu web javascript with only client side javascript?
- Jun 15, 2009 - I wonder how I can reduce the width of the tree javascript dynamic menu?
|