CREATE TABLE menu ( id tinyint(4) NOT NULL auto_increment, parent_id tinyint(4) DEFAULT '0' NOT NULL, name varchar(20), url varchar(60), PRIMARY KEY (id) );
这张表中 id 为索引 parent_id 用来保存上一级菜单的id号,如果是一级菜单则为0 name 为菜单的名称,也就是要在页面上显示的菜单内容 url 如果某菜单为末级菜单,则需要指定该连接的url地址,这个字段就是用来保存此地址的,其他非末级菜单,该字段为空
好了,数据库有了,你就可以添加一些记录了,下面是我做测试的时候,使用的一些记录: INSERT INTO menu VALUES ( '1', '0', '人事管理', ''); INSERT INTO menu VALUES ( '2', '0', '通讯交流', ''); INSERT INTO menu VALUES ( '3', '1', '档案管理', ''); INSERT INTO menu VALUES ( '4', '1', '考勤管理', 'http://localhost/personal/attendance.php'); INSERT INTO menu VALUES ( '5', '2', '通讯录', ''); INSERT INTO menu VALUES ( '6', '2', '网络会议', ''); INSERT INTO menu VALUES ( '7', '3', '新增档案', 'http://localhost/personal/add_achive.php'); INSERT INTO menu VALUES ( '8', '3', '查询档案', 'http://localhost/personal/search_archive.php'); INSERT INTO menu VALUES ( '9', '3', '删除档案', 'http://localhost/personal/delete_archive.php'); INSERT INTO menu VALUES ( '10', '5', '新增通讯记录','http://localhost/communication/add_address.php'); INSERT INTO menu VALUES ( '11', '5', '查询通讯记录', http://localhost/communication/search_address.php'); INSERT INTO menu VALUES ( '12', '5', '删除通讯记录', http://localhost/communication/delete_address.php'); INSERT INTO menu VALUES ( '13', '6', '召开会议', 'http://localhost/communication/convence_meeting.php'); INSERT INTO menu VALUES ( '14', '6', '会议查询', 'http://localhost/communication/search_meeting.php');