Re: foreach help
| From: | jan | Date: | Thu, 31 Jul 2003 08:56:13 +0000 |
| Subject: | Re: foreach help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157683@lists.php.net to get a copy of this message | ||
Hi
try this:
html code for all of checkboxes:
<input type="checkbox" name="ch_box[]" ....>
php code:
if(isset($_POST['ch_box'])) {
foreach($_POST['ch_box'] as $ch_box_id => $ch_box_value) {
processing instructions
}
}
Regards
Jan
On Thu, 2003-07-31 at 03:50, Ryan A wrote:
> Hi,
> I have a set of checkboxes (around 38) which will be sent to me via a
> post(eg: <input name="noPlatform" type="checkbox"
> id="noPlatform"
> value="1>)...if the checkbox is checked then session "noPlatform" should be
> created...AND only the checked ones should be registered all others should
> be unset.
>
> one way to do this would be to something like this:
> $noPlatform = (isset($_POST['noPlatform'])) ? 1 : 0;
> then set the session or via using a if and isset...
>
> but that would mean doing that for the whole 38 fields...I think I have seen
> something like this done via a loop (for, while or foreach or a combination)
> but cant find it in my old mail or the archive.
>
> Thanks in advance,
> -Ryan
>