Re: Checkboxes
| From: | Pavel Jartsev | Date: | Fri, 12 Oct 2001 16:29:56 +0000 |
| Subject: | Re: Checkboxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70940@lists.php.net to get a copy of this message | ||
Intruder wrote:
>
> ...
>
> So, my questions are:
>
> 1)
> are there any more variants which could be "more correct", faster, easier and
> better ??? Just because I don't like them both. First variant is stupid (I used
> it when I started with MySQL/PHP) and second produces more HTML...
>
> 2)
> which variant you'd prefer to use from this two ???
>
> Waiting for reply! ;-)
>
I'd prefer third variant. :)
Generate your checkboxes this way:
printf('<input type="checkbox" name="active[%s]"
%s>',$row["id"],$box);
On PHP-side you'll have $HTTP_POST_VARS['active'], which is array
of values of checked checkboxes. And use just 'for'- or 'foreach'-loop
to update these values into database.
Hope this helps.
--
Pavel a.k.a. Papi