删除无限分类是怎样同时删除它下面的所有子分类?

今天晚上上Q的时候 ,一个以前的学员在网上问我,怎么删除一个无限分类的时候同时删除它下面的所有子分类。我把代码稍微整理了一下,发出来,放在php学员问答里面,方便以后的人查看 。 –北京php培训,就去北京星模实训学校。

$act = isset ($_GET['act']) ? trim ($_GET['act']) : ”;

if ($act == ‘del’)
{
$sort_id = isset ($_GET['id']) ? intval($_GET['id']) : ’0′ ;
$sort_ids = $sort_id;
$childrenIds = getChildrenIds ($sort_id);
if (!empty ($childrenIds))
{
$sort_ids .= $childrenIds;
}
$sql = “D E L E T E   F R O M `article_sort` WHERE `sort_id` in ({$sort_ids})”;
$res = mysql_query ($sql);
if ($res)
{
alert (‘删除成功’);
exit;
}
else
{
alert (‘删除失败’);
exit;
}
}

getChildrenIds 这个函数以前已经给出来过,不清楚的请参考 自定义函数之获取无限分类ID下的子类ID集


Leave Your Comment

Your email will not be published or shared. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

*
请输入图片中的字符以验证你并非垃圾机器人. 点击图片收听验证码的语音版.
点击这里收听此验证码的语音版本