php进阶 无限极分类
2014-02-17 10:43
567 查看
通过排序查找出分类
数据库
CREATE TABLE `infinite_classify1` (
`id` smallint(5) unsigned NOT NULL
AUTO_INCREMENT,
`catpath` varchar(100) NOT NULL,
`title` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
数据库概览
程序代码
<?php
header("content-type:text/html;charset=utf-8");
mysql_connect('localhost','root','910729') or die('链接数据库失败');
mysql_set_charset('utf8');//设定mysql客户机(php)与mysql服务器之间通信的编码
mysql_select_db('test');
$sql="select id,concat(catpath,'-',id) as abspath,title from
infinite_classify1 order by abspath,id";
$result = mysql_query($sql);
//$arr=array();
//$i=0;
//while ($val=mysql_fetch_assoc($result)){
//
$arr[$i]=$val;
//
$i++;
//}
while ($row=mysql_fetch_assoc($result)){
$space =
str_repeat(' ',count(explode('-',$row['abspath']))-1);
echo
$space.$row['title'].'<br>';
}
echo '<pre>';
print_r($arr);
数据库
CREATE TABLE `infinite_classify1` (
`id` smallint(5) unsigned NOT NULL
AUTO_INCREMENT,
`catpath` varchar(100) NOT NULL,
`title` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
数据库概览
程序代码
<?php
header("content-type:text/html;charset=utf-8");
mysql_connect('localhost','root','910729') or die('链接数据库失败');
mysql_set_charset('utf8');//设定mysql客户机(php)与mysql服务器之间通信的编码
mysql_select_db('test');
$sql="select id,concat(catpath,'-',id) as abspath,title from
infinite_classify1 order by abspath,id";
$result = mysql_query($sql);
//$arr=array();
//$i=0;
//while ($val=mysql_fetch_assoc($result)){
//
$arr[$i]=$val;
//
$i++;
//}
while ($row=mysql_fetch_assoc($result)){
$space =
str_repeat(' ',count(explode('-',$row['abspath']))-1);
echo
$space.$row['title'].'<br>';
}
echo '<pre>';
print_r($arr);
相关文章推荐
- some&nbsp;senior&nbsp;topic&nbsp;of&nbsp;php
- php&nbsp;项目依赖时使用Composer
- php无限极分类
- php通过前序遍历树实现无需递归的无限极分类
- android Spinner 分类: Android开发 2014-05-30 10:56 62人阅读 评论(0) 收藏
- android layout_weight讲解ZZ 分类: Android开发 2014-05-30 10:57 37人阅读 评论(0) 收藏
- php字符集转码&nbsp;(兼转载一篇讲解字…
- 编译PHP 出现 undefined…
- 修改Taxonomy term分类列表页…
- Windows&nbsp;Live&nbsp;Writer进阶功能:主动通知搜索引擎,让你的文章马上被收录
- wifi&nbsp;驱动&nbsp;进阶11
- PHP&nbsp;+&nbsp;MySQL&nbsp;分表减低数据库压力
- PHP&nbsp;序列化(serialize)格式详解
- PHP无限极分类
- Weka 分类 注意点
- Windows XP + PHP 5.1.4 + MySQL …
- TP3.2.3 无限极分类&&获取所有子分类包括自身
- 安装使用php&nbsp;zlib扩展实现页面gzip…
- 第1章第2节 操作系统的分类
- mysql+php select 下拉…