Delete question-How do I delete a PHP product category?

Source: Internet
Author: User
You are here: Product category column Category ID classification tree category name parent class ID parent class path commodity classification management 6 Electric 0 0, modify | Copy | Delete 15 black and white machine 6 0, 6, modify | Copy | Delete 27 Washer 6 0, 6, modify | Copy | Remove 28 LCD TV Machine 6 0, 6, modify | Copy | Remove 3 Ladies 0 0, modify | Copy | Delete 12 Casual pants 3 0, 3, modify | Copy | Delete 7 Mobile 0 0, modify | Copy | Delete 8 iphone 7 0, 7, modify | Copy | Delete iphone6s 8 0,7,8, modify | Copy | Delete 9 Huawei 7 0, 7, modify | Copy | Delete 11 Huawei Mate9 9 0,7,9, modify | Copy | Delete Vivo 7 0, 7, modify | Copy | Delete vivoX7 19 0,7,19, modify | Copy | Delete//On the table how do I delete a product category?        Delete parent class = parent + child $id=$_get[' id '];        $sql = "Select path from type WHERE path is like '% $id% '";        $rs =mysql_query ($sql);       $arr =mysql_fetch_assoc ($RS);        if ($arr) {$path = "and path like '% $id% '";        }else{$path = ";        } $where = "where id={$id} {$path}";        $sql 2= "Delete from type $where";        echo $sql 2;die ();        $rs =mysql_query ($sql 2);    if (Mysql_affected_rows () >0) {echo ' delete succeeded ';    }else{Echo ' delete failed '; } break;//The code I wrote why can't I delete a product with a sub-category? Can only execute the order of the parent//where and after the sorting is deleted? For example, the removal of women's clothing, you need to cut off the casual pants before the line, but I would like to delete directly, what should be done??

Reply content:

You are here: Product category column Category ID classification tree category name parent class ID parent class path commodity classification management 6 Electric 0 0, modify | Copy | Delete 15 black and white machine 6 0, 6, modify | Copy | Delete 27 Washer 6 0, 6, modify | Copy | Remove 28 LCD TV Machine 6 0, 6, modify | Copy | Remove 3 Ladies 0 0, modify | Copy | Delete 12 Casual pants 3 0, 3, modify | Copy | Delete 7 Mobile 0 0, modify | Copy | Delete 8 iphone 7 0, 7, modify | Copy | Delete iphone6s 8 0,7,8, modify | Copy | Delete 9 Huawei 7 0, 7, modify | Copy | Delete 11 Huawei Mate9 9 0,7,9, modify | Copy | Delete Vivo 7 0, 7, modify | Copy | Delete vivoX7 19 0,7,19, modify | Copy | Delete//On the table how do I delete a product category?        Delete parent class = parent + child $id=$_get[' id '];        $sql = "Select path from type WHERE path is like '% $id% '";        $rs =mysql_query ($sql);       $arr =mysql_fetch_assoc ($RS);        if ($arr) {$path = "and path like '% $id% '";        }else{$path = ";        } $where = "where id={$id} {$path}";        $sql 2= "Delete from type $where";        echo $sql 2;die ();        $rs =mysql_query ($sql 2);    if (Mysql_affected_rows () >0) {echo ' delete succeeded ';    }else{Echo ' delete failed '; } break;//The code I wrote why can't I delete a product with a sub-category? Can only execute the order of the parent//where and after the sorting is deleted? For example, the removal of women's clothing, you need to cut off the casual pants before the line, but I would like to delete directly, what should be done??

Delete from table where id=7 or path like '%,7,% '

Based on my experience, I have the following suggestions:
1. Classification of commodities when deleting any of the categories, it is necessary to check the library to verify that there are sub-classifications under the classification, and if so, you cannot delete the classification.
2. Before deleting the classification, you must delete all sub-categories below the classification to be able to search the library according to the classification parent ID.
3. If you do not follow the above, the garbage data will be generated.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.