<% Response.Buffer=true %> <% dim page_id dim cat_id page_id = request("page_id") cat_id = request("category_id") '--------------------------------------------------- '-- First we find all this categories decendants and delete them '--------------------------------------------------- call collectChildren(cat_id) '--------------------------------------------------- '-- Now we delete this category '--------------------------------------------------- call deleteCategory(cat_id) '--------------------------------------------------- '-- Redirect back '--------------------------------------------------- Response.Redirect("ia.asp?mode=manageCategories&page_id=" & page_id & "&editType=view&confirmMsg=Category%20deleted") function collectChildren(cat_id) strSQL = "SELECT * FROM epcms_categories WHERE cat_parentid = " & cat_id set rs = LoadRSFromDB(strSQL) if not rs.EOF then Do While not rs.EOF call collectChildren(rs("cat_id")) call deleteCategory(rs("cat_id")) rs.MoveNext Loop end if rs.Close Set rs = Nothing end function function deleteCategory(cat_id) strSQL = "DELETE FROM epcms_categories WHERE cat_id = " & cat_id RunSQL strSQL end function %>