SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    delete folder tree...

    i have a folder tree and the table structure is something like this:

    table category_review
    category_ID = auto increment
    category_name = store all the category names that ive created.
    category_parent = when i add a new category, i will have to choose which category name is my parent.
    category_flag = to differentiate among different categories...different root. for eg. those that are under the same root will have the same category_flag.

    my problem is i dono how to write a delete function. for eg. i have 5 levels. when i delete the third level, all under third level will automatically been deleted.

    i only manage to delete 2 levels using this query:
    Code:
    delete from category_review where category_ID = $category_ID or category_parent = $category_ID
    this query will only delete the third level, and the fourth level.

    any suggestions on how to delete?

  2. #2
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anybody?? help help..

    guess my question is not clear enough.

    for eg.
    3 levels in a folder tree, 3 levels also means 3 categories.

    Code:
    1. Book
        1.1. PHP 
            1.1.1. PHP Programming for Beginners
            1.1.2. PHP Programming for Professionals
                      1.1.2.1 First Version
                      1.1.2.2 Second Version
        1.2. ASP
            1.1.1. ASP Programming for Beginners
            1.1.2. ASP Programming for Professionals
    if i delete 1.1PHP, means the levels under PHP hv to be deleted too. how am i suppose to generate the sql query to delete?

  3. #3
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm..that only will delete one level...

    ok, if i want to delete 1.1? this will only delete 1.1 but not others rite?

    my table structure is like this:
    Code:
    ___________________________________________________
    category_ID | category_name | category_parent | category_flag
    ___________________________________________________
    
            1         |         Books          |               0          |            1
    ----------------------------------------------------------------------------------
            2          |        PHP             |             1            |            1
    ---------------------------------------------------------------------------------
            3          |     PHP P F Beg    |              2           |           1
    ----------------------------------------------------------------------------------
            4          |      PHP P F Pro    |             2            |            1
    ----------------------------------------------------------------------------------
            5          |      First Version   |             4            |            1
    ----------------------------------------------------------------------------------
            6          |  Second Version  |             4             |           1
    ----------------------------------------------------------------------------------
            7          |        ASP              |             1             |            1
    ----------------------------------------------------------------------------------
            8          |     ASP P F Beg     |             7             |            1
    ----------------------------------------------------------------------------------
            9          |     ASP P F Pro     |              7            |             1
    ----------------------------------------------------------------------------------


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •