Re: Is there a way to display data from database for SelectOptions in a form?
| From: | Jochem Maas | Date: | Tue, 10 Jan 2006 17:15:18 +0000 |
| Subject: | Re: Is there a way to display data from database for SelectOptions in a form? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-228426@lists.php.net to get a copy of this message | ||
Jay Paulson (CE CEN) wrote:
[snip]Let's look at it another way, why 70-80 lines of code when 4 will do it properly when done correctly?[/snip]4 * 20 = 80 so after having created 20 dynamic select boxes the function wins it. I really don't think that performance here is the issue - one should tackle that with suitable caching not writing unmanagable speed-freak-code. on top of that there is a high chance that the 4 lines will be copy/pasted quite often - a great way to replicate small little errors. in contrast to the function which keeps the 'template' HMTL output (of the select box) in a single place (handy for making site wide changes - for instance all a requirement that means all selectboxes must have a certain class attribute value?) another advantage of the function is that it takes into account attributes/functionality that you might not need in this particular case now - but might come in handy. using the function means not having to hack stuff in later)
I agree with this line of thinking especially for a new person to php. When I first read the solution that was so long I thought to myself "great and this person is new to php and now they are going to be scared of php."Sue .... DON'T PANIC (sorry for the lack of friendly letters) (the fear argument doesn't wash with me btw; if Sue has more questions she should fire away!) (with regard to fear: go read some Krishnamurti or have children or something - either you go mad or you get over it ;-)
I really think one of the appeals of php is it's simplicity of getting things done and getting those things done quickly. Yes it's great having one function to output every select html form but is it really necessary?sheesh - it's not [YouMustBeJokingIfYouThinkDevelopingWithThisIs]QuickForm (the 'YouMustBeJokingIfYouThinkDevelopingWithThisIs' is silent ;-)