-
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 
-
-
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.
-
-
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
-
-
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.
-
-
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
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks