|
Posted by Geoff Berrow on 03/24/06 21:54
Message-ID: <1143225322.387767.284600@u72g2000cwu.googlegroups.com> from
Ken Robinson contained the following:
>> > <INPUT TYPE="checkbox" NAME="cb123" VALUE="on">Category Description
>> > <INPUT TYPE="checkbox" NAME="cb137" VALUE="on">Category Description
>
>A different way to do this is
>
><INPUT TYPE="checkbox" NAME="cb[123]" VALUE="on">Category Description
><INPUT TYPE="checkbox" NAME="cb[137]" VALUE="on">Category Description
>
>Then in you PHP, you can do
><?php
>if (isset($_POST['cb']))
> foreach $_POST['cb'] as $key=>$dmy)
> echo 'You chose catagory ' . $key . '<br>';
>?>
If he's getting the values from a db it may be slightly easier to do
this:
<INPUT TYPE="checkbox" NAME="cat[]" VALUE="cb123">Category Description
<INPUT TYPE="checkbox" NAME="cat[]" VALUE="cb137">Category Description
<?php
if (isset($_POST['cat'])){
foreach $_POST['cat'] as $value){
echo 'You chose category ' . $value . '<br>';
}
}
Values will only exist if checkboxes are checked.
>?>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Navigation:
[Reply to this message]
|