Results 1 to 8 of 8

Thread: Multi level categories

  1. #1
    Join Date
    Apr 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Multi level categories

    Hi,

    I cannot seem to find any articles about multi level categories and sub categories in php.

    I only know how to create a 1 level categories only. Does anyone know how or could point me into the right direction?
    thanks in advance.
    Sami

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Categories of what?

    A filesystem setup will work, as will a tree setup with a database, where you have a table of "folders," each of which except the root has exactly one parent referenced.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I meant like using mkdir() to make a dir and add subdir into it.

    I think it is something like this:

    Top Level
    - Sub1
    - Sub1_1
    - Sub1_2
    - Sub2
    - Sub3

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    mkdir('dir/subdir');
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm learning how to explain this.

    Just say that I a top level category or directory and I wanted to create very very deep into that category.

    Like this...

    Top Level > x > xx> and etc... nn>vv

    So how would you create that from a php script. thanks.

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm so confused about even the general idea of what you are doing.

    you're making folders on the site, right?

    So... mkdir('a/b/c/d/e/.../z/whatever'); ?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    With PHP5, you can:
    Code:
    mkdir('x/xx/blah/nn/vv', 0777, true);
    However, in earlier versions you'd have to do it one at a time:
    Code:
    $pathname = 'x/xx/blah/nn/vv';
    $dirs = explode('/', $pathname);
    foreach($dirs as $i => $dir)
      mkdir(implode('/', array_slice($dirs, 0, $i + 1)));
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Oh, I didn't think of that. I was just accessing the folder, forgetting that I was creating it as that function. How silly.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •