教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 无限分类&树型论坛的实现

无限分类&树型论坛的实现

发布时间:2016-10-27   编辑:jiaochengji.com
教程集为您提供无限分类&树型论坛的实现等资源,欢迎您收藏本站,我们将为您提供最新的无限分类&树型论坛的实现资源
数据表参考:
代码:--------------------------------------------------------------------------------
CREATE TABLE `mf_sort` (
`sortid` SMALLINT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`main` TINYINT( 2 ) UNSIGNED NOT NULL ,
`parentid` SMALLINT( 3 ) UNSIGNED NOT NULL ,
`layer` SMALLINT( 3 ) UNSIGNED NOT NULL ,
`orders` TINYINT( 2 ) UNSIGNED NOT NULL ,
`sort` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `sortid` ) ,
INDEX ( `main` , `parentid` , `layer` , `orders` )
);
--------------------------------------------------------------------------------
关键的函数
PHP代码:--------------------------------------------------------------------------------
function get_main_layer_orders($parentid)
{
global $x_db;
$sql = "select `main`, `layer`, `orders` ";
$sql .= "from `mf_sort` ";
$sql .= "where `postid`='$parentid'";
$x_db->exec($sql);
$data = $x_db->get_data();
$layer = $data[0]['layer'] 1;
$main = $data[0]['main'];
$orders = $data[0]['orders'];
$sql = "select `sortid` from `mf_sort` ";
$sql .= "where `parentid`='$parentid'";
$x_db->exec($sql);
$n = $x_db->n;
if ($n>0)
{
$lastid = $parentid;
get_lastid($lastid);
$sql = "select `orders` from `mf_sort` ";
$sql .= "where `sortid`='$lastid'";
$x_db->exec($sql);
$data = $x_db->get_data();
$orders = $data[0][0];
$sql = "update `mf_sort` ";
$sql .= "set `orders`=`orders` 1 ";
$sql .= "where `orders`>$orders and `main`='$main'";
$x_db->exec($sql);
$orders = $orders 1;
return array($main, $layer, $orders);
}

您可能感兴趣的文章:
JSP实现论坛树型结构的具体算法
无限分类&树型论坛的实现
JS 树形控件 MzTreeView
数据结构-树和二叉树(Golang)
Python中的树你知道吗?
php与mysql实现的无限级分类
PHP 无限分类程序代码
php 实现无限级树型示例演示
树型论坛递归加速
jQuery树型菜单 MagicDTree

[关闭]
~ ~