CREATE TABLE IF NOT EXISTS `deepcate` (
`id` int(4) NOT NULL,
`pid` int(11) NOT NULL,
`catename` varchar(30) NOT NULL,
`cateorder` int(11) unsigned NOT NULL DEFAULT '0',
`createtime` int(10) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='cms类型表';
--
-- 转存表中的数据 `deepcate`
--
INSERT INTO `deepcate` (`id`, `pid`, `catename`, `cateorder`, `createtime`) VALUES
(1, 0, '新闻', 0, 0),
(2, 0, '图片', 0, 0),
(3, 1, '国内新闻', 0, 0),
(4, 1, '国际新闻', 0, 0),
(5, 3, '北京新闻', 0, 0),
(6, 4, '美国新闻', 0, 0),
(7, 2, '美女图片', 0, 0),
(8, 2, '风景图片', 0, 0),
(9, 7, '日韩明星', 0, 0),
(10, 9, '日本AV', 0, 0);
输出下拉菜单
查询结构代码
初始化数据库
<?php header("Content-type: text/html; charset=utf-8"); $db_name = 'infiniteclass'; $host = 'localhost'; $user = 'root'; $password = '123456'; $link = null; //初始化数据库连接 function initDB($db_name,$host,$user,$password){ global $link; $link = mysqli_connect($host,$user,$password,$db_name); if (!$link){ die('数据库链接失败'); } mysqli_query($link,'set names utf8'); } //查询函数 function query($str){ global $link; $res = mysqli_query($link,$str); if (!$res){ return '查询失败'; }else{ return $res; } } initDB($db_name,$host,$user,$password);