generating the menu_data file using mysql and php

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
System7
Advanced
Advanced
Posts: 10
Joined: Fri Nov 07, 2003 8:38 pm

generating the menu_data file using mysql and php

Post by System7 »

ok i hope someone can help

i know this is possible cuz the milonic site does it well i assume they do because in there source you can see menu_data.php as there script source

k so in my main page i have this

Code: Select all

<? 
		$sql = "SELECT * FROM menu WHERE menuname = 'mainmenu'";
    	    $result = mysql_query($sql);
			while ($row = mysql_fetch_row($result))  {
				if ($row[4] != ""){ //row[4] = showmenu, if showmenu!="" then
					echo "<a href=\"$row[3]\" class=\"menu\" onmouseover=\"popup('$row[4]',1)\" onmouseout=popdown()>$row[2]</a>\n";
				}
				else { //row[4] = showmenu, if showmenu="" then 
					echo "<a href=\"$row[3]\" class=\"menu\">$row[2]</a>\n";
				}
			}
	?>		
k now that works fine
the tables in my database are set up like so
id , menuname , title , url , showmenu

now in my menu_data.php file i have the following

Code: Select all

_menuCloseDelay=500           // The time delay for menus to remain visible on mouse out
_menuOpenDelay=150            // The time delay before menus open on mouse over
_followSpeed=5                // Follow scrolling speed
_followRate=40                // Follow scrolling Rate
_subOffsetTop=10              // Sub menu top offset
_subOffsetLeft=-10            // Sub menu left offset
_scrollAmount=3               // Only needed for Netscape 4.x
_scrollDelay=20               // Only needed for Netcsape 4.x


with(menuStyle=new mm_style()){
onbgcolor="#EDEDED";
oncolor="#000000";
offbgcolor="#3D3D3D";
offcolor="#E5E5E5";
padding=1;
fontsize=11;
fontstyle="normal";
separatorsize=10;
separatorcolor="#3D3D3D";
fontfamily="Arial Narrow";
overfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color='#777777', Direction=135, Strength=5)";
outfilter="randomdissolve(duration=0.3)";
}

<?
	$i=0;
	$sql = "SELECT * FROM menu WHERE menuname != 'mainmenu'";
    $result = mysql_query($sql);
	while ($row = mysql_fetch_row($result))  {
		$name[$i] = $row[1];
		$sql .= " && menuname != '$name[$i]' ";		
		echo "with(milonic=new menuname(\"$row[1]\")){\n";
		echo "style=menuStyle;\n";
		echo "overflow=\"scroll\";\n";
		$sql2 = "SELECT * FROM menu WHERE menuname = '$name[$i]'";
	    $result2 = mysql_query($sql2);			
		$i++;	
		while ($row = mysql_fetch_row($result2))  {
			if($row[4] == "" && $row[3] != ""){
				echo "aI(\"text=$row[2];url=$row[3];\");\n";
			} elseif ($row[4]!="" && $row[3] != "") {
				echo "aI(\"text=$row[2];\");\n";
			} elseif ($row[4]!="" && $row[3] = "") {
				echo "aI(\"text=$row[2];showmenu=$row[4];\");\n";
			}
		}
		echo "}\n";
		
	}
?>
drawMenus();
now this works except theres one problem that i thought the line

Code: Select all

$sql .= " && menuname != '$name[$i]' ";
would solve but it hasnt. the problem is that for ever element under a menu it creates that many menu's heres a sample of what my menu_data.php file looks like if you view teh source after this script as run

Code: Select all

_menuCloseDelay=500           // The time delay for menus to remain visible on mouse out
_menuOpenDelay=150            // The time delay before menus open on mouse over
_followSpeed=5                // Follow scrolling speed
_followRate=40                // Follow scrolling Rate
_subOffsetTop=10              // Sub menu top offset
_subOffsetLeft=-10            // Sub menu left offset
_scrollAmount=3               // Only needed for Netscape 4.x
_scrollDelay=20               // Only needed for Netcsape 4.x


with(menuStyle=new mm_style()){
onbgcolor="#EDEDED";
oncolor="#000000";
offbgcolor="#3D3D3D";
offcolor="#E5E5E5";
padding=1;
fontsize=11;
fontstyle="normal";
separatorsize=10;
separatorcolor="#3D3D3D";
fontfamily="Arial Narrow";
overfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color='#777777', Direction=135, Strength=5)";
outfilter="randomdissolve(duration=0.3)";
}

with(milonic=new menuname("area_office")){
style=menuStyle;
overflow="scroll";
aI("text=CPAC;url=index.php?page=area_office&section=CPAC;");
aI("text=AMT;url=index.php?page=area_office&section=AMT;");
aI("text=AHT;url=index.php?page=area_office&section=AHT;");
}
with(milonic=new menuname("area_office")){
style=menuStyle;
overflow="scroll";
aI("text=CPAC;url=index.php?page=area_office&section=CPAC;");
aI("text=AMT;url=index.php?page=area_office&section=AMT;");
aI("text=AHT;url=index.php?page=area_office&section=AHT;");
}
with(milonic=new menuname("area_office")){
style=menuStyle;
overflow="scroll";
aI("text=CPAC;url=index.php?page=area_office&section=CPAC;");
aI("text=AMT;url=index.php?page=area_office&section=AMT;");
aI("text=AHT;url=index.php?page=area_office&section=AHT;");
}
so you can see it is creating a menu for each item in the menu if anyone can help me fix this it would be a great help right now i cant think of what
_shft.void(7)
System7
Advanced
Advanced
Posts: 10
Joined: Fri Nov 07, 2003 8:38 pm

Post by System7 »

nm figured it out
_shft.void(7)
liyenn
Beginner
Beginner
Posts: 5
Joined: Thu Dec 07, 2006 5:44 am

Post by liyenn »

i've been looking for solution on this same matter...
can i know how to make it work please???
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

There's a demo in /extras/ in the system download. Did you check that?
John
liyenn
Beginner
Beginner
Posts: 5
Joined: Thu Dec 07, 2006 5:44 am

Post by liyenn »

John wrote:There's a demo in /extras/ in the system download. Did you check that?
sorry,i'm still not familiar with this website as this is the 1st day i found it..

can you show me where is the system download is?

thank you!
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

The download page is here.
John
liyenn
Beginner
Beginner
Posts: 5
Joined: Thu Dec 07, 2006 5:44 am

Post by liyenn »

John wrote:The download page is here.
thanks for your reply!!!!!!

thanks a lot!

i'll go to check it out now ;)
liyenn
Beginner
Beginner
Posts: 5
Joined: Thu Dec 07, 2006 5:44 am

Post by liyenn »

i'm trying on the php_mysql based menu...
i installed the database and try to run it from localhost, however, why it appeared as below? i thought it suppose to be a menu? did imisunderstand anything?

Code: Select all


Beta files are downloadable from here: mysqlmenu.zip 

Here is the database scheme for mini_menu.sql 

If you are looking for ASP/SQLServer, here it is: asp_sql_datamenus.zip 
#
# Table structure for table `mm_items`
#

CREATE TABLE `mm_items` (
  `itemid` int(11) NOT NULL auto_increment,
  `menuid` int(11) NOT NULL default '0',
  `text` text,
  `url` varchar(255) default NULL,
  `showmenu` varchar(40) default NULL,
  PRIMARY KEY  (`itemid`)
) TYPE=MyISAM AUTO_INCREMENT=50 ;

#
# Dumping data for table `mm_items`
#

INSERT INTO `mm_items` VALUES (1, 1, 'MILONIC', 'http://milonic.com', NULL);
INSERT INTO `mm_items` VALUES (2, 1, 'Sample Menus', NULL, 'Menu Samples');
INSERT INTO `mm_items` VALUES (3, 1, 'About Milonic', NULL, 'About Milonic');
INSERT INTO `mm_items` VALUES (4, 1, 'Partners', NULL, 'Partners');
INSERT INTO `mm_items` VALUES (5, 1, 'Links', NULL, 'Links');
INSERT INTO `mm_items` VALUES (6, 2, 'Horizontal Navigational Menu', NULL, NULL);
INSERT INTO `mm_items` VALUES (7, 2, 'Vertical Navigational Menu', '/menusample2.php', NULL);
INSERT INTO `mm_items` VALUES (8, 2, 'All Horizontal Menus', '/menusample25.php', NULL);
INSERT INTO `mm_items` VALUES (9, 2, 'Using the popup function Fixed Position', '/menusample3.php', NULL);
INSERT INTO `mm_items` VALUES (10, 2, 'Using the popup Positioned by Images', 'menusample24.php', NULL);
INSERT INTO `mm_items` VALUES (11, 2, 'Image Map Sample', 'menusample4.php', NULL);
INSERT INTO `mm_items` VALUES (12, 2, 'Multiple Styles', 'menusample5.php', NULL);
INSERT INTO `mm_items` VALUES (13, 2, 'Menus and Tool Tips', 'menusample6.php', NULL);
INSERT INTO `mm_items` VALUES (14, 2, 'Multiple Colored Menus', 'menusample7.php', NULL);
INSERT INTO `mm_items` VALUES (15, 2, 'Menu Items as Headers', 'menusample8.php', NULL);
INSERT INTO `mm_items` VALUES (16, 2, 'Windows XP Style Menus', 'menusample12.php', NULL);
INSERT INTO `mm_items` VALUES (17, 2, 'Windows 98 Style Menus', 'menusample13.php', NULL);
INSERT INTO `mm_items` VALUES (18, 2, 'Relative Positioning (Table Bound)', 'menusample9.php', NULL);
INSERT INTO `mm_items` VALUES (19, 2, 'Follow Scrolling', 'menusample10.php', NULL);
INSERT INTO `mm_items` VALUES (20, 2, 'Opening Windows & Frames', 'menusample11.php', NULL);
INSERT INTO `mm_items` VALUES (21, 2, 'Hiding DIVs when displaying menus', 'menusample14.php', NULL);
INSERT INTO `mm_items` VALUES (22, 2, 'Activating MouseOver & MouseOut Functions', 'menusample15.php', NULL);
INSERT INTO `mm_items` VALUES (23, 2, 'Dynamic Dragable Menus', 'menusample22.php', NULL);
INSERT INTO `mm_items` VALUES (24, 2, 'Positioning with screenposition & offsets', 'menusample23.php', NULL);
INSERT INTO `mm_items` VALUES (25, 2, '100% Width Span Menu', 'menusample26.php', NULL);
INSERT INTO `mm_items` VALUES (26, 2, 'Context Right Click Menu', 'menusample27.php', NULL);
INSERT INTO `mm_items` VALUES (27, 2, 'Static Images Sample', 'menusample16.php', NULL);
INSERT INTO `mm_items` VALUES (28, 2, 'Rollover/swap Images', 'menusample17.php', NULL);
INSERT INTO `mm_items` VALUES (29, 2, 'Menus built from images', 'menusample18.php', NULL);
INSERT INTO `mm_items` VALUES (30, 2, 'Images as Menu Backgrounds', 'menusample19.php', NULL);
INSERT INTO `mm_items` VALUES (31, 2, 'Background Menu Item Images', 'menusample20.php', NULL);
INSERT INTO `mm_items` VALUES (32, 3, 'Product Purchasing Page', 'http://milonic.com/cbuy.php', NULL);
INSERT INTO `mm_items` VALUES (33, 3, 'Contact Us', 'http://milonic.com/contact.php', NULL);
INSERT INTO `mm_items` VALUES (34, 3, 'Newsletter Subscription', 'http://milonic.com/newsletter.php', NULL);
INSERT INTO `mm_items` VALUES (35, 3, 'FAQ', 'http://milonic.com/menufaq.php', NULL);
INSERT INTO `mm_items` VALUES (36, 3, 'Discussion Forum', 'http://milonic.com/forum/', NULL);
INSERT INTO `mm_items` VALUES (37, 3, 'Software License Agreement', 'http://milonic.com/license.php', NULL);
INSERT INTO `mm_items` VALUES (38, 3, 'Privacy Policy', 'http://milonic.com/privacy.php', NULL);
INSERT INTO `mm_items` VALUES (39, 4, '(aq) Web Hosting', 'http://www.a-q.co.uk/', NULL);
INSERT INTO `mm_items` VALUES (40, 4, 'SMS 2 Email', 'http://www.sms2email.com/', NULL);
INSERT INTO `mm_items` VALUES (41, 4, 'WebSmith', 'http://www.websmith.com/', NULL);
INSERT INTO `mm_items` VALUES (42, 5, 'Apache Web Server', 'http://www.apache.org/', NULL);
INSERT INTO `mm_items` VALUES (43, 5, 'MySQL Database Server', 'http://ww.mysql.com/', NULL);
INSERT INTO `mm_items` VALUES (44, 5, 'PHP - Development', 'http://www.php.net/', NULL);
INSERT INTO `mm_items` VALUES (45, 5, 'phpBB Web Forum System', 'http://www.phpbb.net/', NULL);
INSERT INTO `mm_items` VALUES (46, 5, 'Anti Spam Tools', '', 'antispam');
INSERT INTO `mm_items` VALUES (47, 6, 'Spam Cop', 'http://www.spamcop.net/', NULL);
INSERT INTO `mm_items` VALUES (48, 6, 'Mime Defang', 'http://www.mimedefang.org/', NULL);
INSERT INTO `mm_items` VALUES (49, 6, 'Spam Assassin', 'http://www.spamassassin.org/', NULL);

# --------------------------------------------------------

#
# Table structure for table `mm_menus`
#

CREATE TABLE `mm_menus` (
  `menuid` int(11) NOT NULL auto_increment,
  `projectid` int(11) NOT NULL default '0',
  `styleid` int(11) NOT NULL default '0',
  `name` varchar(40) NOT NULL default '',
  `alwaysvisible` tinyint(1) default NULL,
  `orientation` tinyint(1) default NULL,
  `overflow` varchar(20) default NULL,
  PRIMARY KEY  (`menuid`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;

#
# Dumping data for table `mm_menus`
#

INSERT INTO `mm_menus` VALUES (1, 1, 1, 'Main Menu', 1, 1, NULL);
INSERT INTO `mm_menus` VALUES (2, 1, 1, 'Menu Samples', NULL, NULL, 'scroll');
INSERT INTO `mm_menus` VALUES (3, 1, 1, 'About Milonic', NULL, NULL, NULL);
INSERT INTO `mm_menus` VALUES (4, 1, 1, 'Partners', NULL, NULL, NULL);
INSERT INTO `mm_menus` VALUES (5, 1, 1, 'Links', NULL, NULL, NULL);
INSERT INTO `mm_menus` VALUES (6, 1, 1, 'AntiSpam', NULL, NULL, NULL);

# --------------------------------------------------------

#
# Table structure for table `mm_projects`
#

CREATE TABLE `mm_projects` (
  `projectid` int(11) NOT NULL auto_increment,
  `menuCloseDelay` int(11) NOT NULL default '500',
  `menuOpenDelay` int(11) NOT NULL default '150',
  `subOffsetTop` tinyint(1) NOT NULL default '0',
  `subOffsetLeft` tinyint(1) NOT NULL default '0',
  `name` varchar(100) default NULL,
  PRIMARY KEY  (`projectid`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

#
# Dumping data for table `mm_projects`
#

INSERT INTO `mm_projects` VALUES (1, 500, 150, 2, -3, 'Minimalist Menu');

# --------------------------------------------------------

#
# Table structure for table `mm_styles`
#

CREATE TABLE `mm_styles` (
  `styleid` int(11) NOT NULL auto_increment,
  `name` varchar(40) NOT NULL default '',
  `oncolor` varchar(6) default NULL,
  `onbgcolor` varchar(6) default NULL,
  `offcolor` varchar(6) default NULL,
  `offbgcolor` varchar(6) default NULL,
  `padding` tinyint(4) default NULL,
  `separatorsize` tinyint(4) default NULL,
  `borderwidth` tinyint(4) default NULL,
  `fontfamily` varchar(25) default NULL,
  `fontsize` varchar(6) default NULL,
  PRIMARY KEY  (`styleid`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

#
# Dumping data for table `mm_styles`
#

INSERT INTO `mm_styles` VALUES (1, 'miniStyle', 'FFFFFF', '4F8EB6', '000000', 'FFFFFF', 3, 1, 1, 'verdana', '10px');
    

liyenn
Beginner
Beginner
Posts: 5
Joined: Thu Dec 07, 2006 5:44 am

Post by liyenn »

ok, i got it shown already...

now trying to apply it to my application..

=)

thanks!
rcappuccio
Beginner
Beginner
Posts: 3
Joined: Sun Feb 04, 2007 7:37 pm

I can't see the menu

Post by rcappuccio »

liyenn wrote:ok, i got it shown already...

now trying to apply it to my application..

=)

thanks!
Hi liyenn how did you do to show the menu...i can´t make it work. I need the info urgently.
Post Reply