Copy codeThe Code is as follows:
$ Act = isset ($ _ GET ['ac'])? Trim ($ _ GET ['ac']): ";
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 = "delete from 'Article _ sort 'WHERE 'sort _ id' in ({$ sort_ids })";
$ Res = mysql_query ($ SQL );
If ($ res)
{
Alert ('deleted successfully ');
Exit;
}
Else
{
Alert ('deletion failed ');
Exit;
}
}
The getChildrenIds function has been provided before. For details, refer to the custom function to obtain the subclass ID set under the infinite category ID.
UDF to obtain the subclass ID set under an infinite category ID
Copy codeThe Code is as follows:
/*------------------*/
//-Obtain the subclass ID set under the infinite category ID
//-$ Sort_id = $ sort_id.getChildrenIds ($ sort_id );
//-$ SQL = "..... Where sort_id in ($ sort_id )";
/*------------------*/
Function getChildrenIds ($ sort_id)
{
Global $ db;
$ Ids = ";
$ SQL = "SELECT * FROM". $ db-> table ('Article _ sort '). "WHERE 'parent _ id' =' {$ sort_id }'";
$ Res = $ db-> query ($ SQL );
If ($ res)
{
While ($ row = $ db-> fetch_assoc ($ res ))
{
$ Ids. = ','. $ row ['sort _ id'];
$ Ids. = getChildrenIds ($ row ['sort _ id']);
}
}
Return $ ids;
}