Results 1 to 5 of 5

Thread: If, Else Statements - any limits or other solution?

  1. #1
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default If, Else Statements - any limits or other solution?

    I am trying to have a field auto enter data after a user selects an item from a select list. The select list contains 456 items and the result list is one of 76 items. How best would I do this with php, or should I be using javascript? It will need to update again if the user goes back to the select list and changes it - i.e. recheck the data and re-enter the result into the result field.

    Thanks
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    enter data into what? a database? an email? a subsequent page?

    PHP is a fine solution, if the processing is taking place server-side. You could probably use a foreach statement more efficiently than if...else, but we'd have to see your code and know more about what you want to do, exactly.

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

    Default

    You could also try to use switch statements. Basically it's a shorter way to do if/else which just returns a certain value.

    http://www.php.net/manual/en/control...res.switch.php

    It's a little weird and only useful in a few situations, but if it applies and you have a lot of data, it can make your list a bit shorter.
    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

  4. #4
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    For a list that big, you should use a database.

    You'll be able to create the html for the select list with a loop.

    Once you have the list item the user selected, then it is just a matter of querying the database to determine which of the 76 result items you need to return.

    Hand coding a html select with 476 items must be a nightmare.

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

    Default

    Or a flat file "database" might work.
    If you have data and you want to store it and search it, a real database is always the best solution. It also makes it much easier to manage later if you want to expand/upgrade, etc.
    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
  •