if(!empty($_POST["cat"])&&!empty($_GET["id"]))
{
$ext_table=$config['table_pre'].'defind_'.$_POST['ext_field_cat'];
$_POST['ext_field_cat']*=1;
if($_POST['pid']!=0)
{
if($_POST["pid"]!==substr($_GET['id'],0,strlen($_GET['id'])-2))
{
$s=$_POST["pid"]."00";
$b=$_POST["pid"]."99";
$sql="select max(catid) as catid from $cat_table where catid>$s and catid<$b";
$db->query($sql);
$re=$db->fetchRow();
$id=$re["catid"];
if(!$id)
$id=$_POST["pid"]."01";
else
$id=$id+1;
}
else
$id=$_GET['id'];
//修改当时类别信息
$sql="update $cat_table set catid='$id', cat='".$_POST['cat']."',isindex='".$isindex."'
,pic='$_POST[pic]',brand='$_POST[brand]',ext_table='$ext_table',ext_field_cat='$_POST[ext_field_cat]',template='$_POST[template]' where catid='".$_GET['id']."'";
$re=$db->query($sql);
//假如当时类别下面带有子类别把子类别一同移过去
$s=$_GET['id']."00";
$b=$_GET['id']."99";
$sql="update $cat_table set catid=replace(catid,$_GET[id],$id) where catid>=$s and catid<=$b";
$re=$db->query($sql);
}