Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,682
    Thanks
    80
    Thanked 4,646 Times in 4,608 Posts
    mmaar: Great. That's what I was looking for.

    Now let me figure out what you need from that.

    But I've got a hot project due today, so it may be tomorrow.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  2. #17
    New Coder
    Join Date
    Feb 2013
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    mmaar: Great. That's what I was looking for.

    Now let me figure out what you need from that.

    But I've got a hot project due today, so it may be tomorrow.
    That's alright, I'm in no rush. Thank you so much for helping me with this!

  3. #18
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,682
    Thanks
    80
    Thanked 4,646 Times in 4,608 Posts
    Okay. This table design is less than ideal. Obviously created by an amateur in the world of multi-level categories.

    If it were mine, I would throw it away and create my own, but I'm sure you don't have that luxury.

    Under the circumstances, you really do not have any choice but to create what I call "dependent selects" or "dependent drop-downs".

    That is, first you will show all the top-level categories in one <select>.

    Then, *AFTER* the user chooses a top-level category, you show all the first level subcategories.

    Then, *AFTER* the user chooses a first level subcategory, you show all the second level subcategories.

    And so on, for as many levels as you choose.

    I have to say, this is some really really bad data.

    Just to pick a couple of examples from *ONLY* the records you showed me, we have these "chains":

    TV-Shows ==> Buffy the Vampire Slayer ==> Characters ==> Angel
    TV-Shows ==> Angel

    (Is there really a TV show named "Angel"??)

    Ugh. I really really hate this.

    **************

    Well, anyway, you have three choices on how to do this:
    (1) Dump the *ENTIRE* "videos_categories" table into a *JAVASCRIPT* array (using PHP to do that, of course), and then do all the work in Javascript.

    (2) Use ONLY PHP. So that each time the user makes another selection in a <select> list, you send all the data back to your PHP page which rebuilds the page with the new subcategory, etc.

    (3) A hybrid. PHP generates the page with the first <select>. Then, when the user makes a choice from that <select>, you use JavaScript to make an AJAX request back to the server to get the list of options for the next level <select>.

    *************
    (1) and (2) are the easier. Kind of a toss up as to which is easier, depending on how good your PHP coding is compared to your JavaScript coding.

    (3) is generally acknowledged to be the best user interface, but it's the hardest to write, since you need to be good in both JavaScript and PHP.

    ************
    What do you think?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  4. #19
    New Coder
    Join Date
    Feb 2013
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Okay. This table design is less than ideal. Obviously created by an amateur in the world of multi-level categories.

    If it were mine, I would throw it away and create my own, but I'm sure you don't have that luxury.

    Under the circumstances, you really do not have any choice but to create what I call "dependent selects" or "dependent drop-downs".

    That is, first you will show all the top-level categories in one <select>.

    Then, *AFTER* the user chooses a top-level category, you show all the first level subcategories.

    Then, *AFTER* the user chooses a first level subcategory, you show all the second level subcategories.

    And so on, for as many levels as you choose.

    I have to say, this is some really really bad data.

    Just to pick a couple of examples from *ONLY* the records you showed me, we have these "chains":

    TV-Shows ==> Buffy the Vampire Slayer ==> Characters ==> Angel
    TV-Shows ==> Angel

    (Is there really a TV show named "Angel"??)

    Ugh. I really really hate this.

    **************

    Well, anyway, you have three choices on how to do this:
    (1) Dump the *ENTIRE* "videos_categories" table into a *JAVASCRIPT* array (using PHP to do that, of course), and then do all the work in Javascript.

    (2) Use ONLY PHP. So that each time the user makes another selection in a <select> list, you send all the data back to your PHP page which rebuilds the page with the new subcategory, etc.

    (3) A hybrid. PHP generates the page with the first <select>. Then, when the user makes a choice from that <select>, you use JavaScript to make an AJAX request back to the server to get the list of options for the next level <select>.

    *************
    (1) and (2) are the easier. Kind of a toss up as to which is easier, depending on how good your PHP coding is compared to your JavaScript coding.

    (3) is generally acknowledged to be the best user interface, but it's the hardest to write, since you need to be good in both JavaScript and PHP.

    ************
    What do you think?
    Thanks, I'll try the first or second option in two weeks as I'm going on holiday tomorrow. I'll let you know if it works.

    Thank you so much for all the help!

  5. #20
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,682
    Thanks
    80
    Thanked 4,646 Times in 4,608 Posts
    Should have noted: Option 1 is only viable if your entire table has no more than a couple of thousand rows (records). Option 2 is possible no matter how big the table is. (And ditto option 3.)
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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