数据表参考:
代码:--------------------------------------------------------------------------------
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);
}
http://www.bkjia.com/phpjc/629306.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/629306.htmltecharticle数据表参考: 代码:-------------------------------------------------------------------------------- create table `mf_sort` ( `sortid` smallint( 3 ) unsigned not null auto_incre...
