Re: checkboxes
| From: | Brent Baisley | Date: | Wed, 30 Nov 2005 14:37:44 +0000 |
| Subject: | Re: checkboxes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226641@lists.php.net to get a copy of this message | ||
Excellent response. You should always be expecting certain data. So if no checkboxes are checked, your code should realize that since it was expecting the data and none was submitted.
The "lazy way" is much easier to code, but it is actually fairly efficient. You are only hitting the database twice, once of the delete and once for the bulk insert. On a fixed record length table, the lazy way may actually be quicker.
On Nov 30, 2005, at 2:23 AM, Curt Zirzow wrote:
So we have a form that will eventually need to knnow what values should be selected. Potentially data alreadly exists that may have the same records. There are two options (or perhaps more) to approach this: Decide as we go approach and clean up: 1) Grap the 'vehicles' currently assoicated with the 'lot' 2) if 'vehicle' is currently selected do nothing 3) if 'vehicle' is a new item we should add 'vehicle' as long as it-- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577is a valid 'vehicle;4) repeat 2 and 3 until we looked at all the data 5) figure out which ones should be deleted and delete them. Forget everything, we'll add what is valid (the lazy way): 1) delete every associated record to the 'lot' 2) for each 'vehicle' add 'vehicle' as long as it is a valid'vehicle'