Re: checkboxes
| From: | Bastian Vogt | Date: | Fri, 22 Nov 2002 11:20:45 +0000 |
| Subject: | Re: checkboxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125590@lists.php.net to get a copy of this message | ||
hi,
your missing some brackets "[]"!
this should work better:
<td><input type="checkbox" name="val[]" value="a" />
AAA</td>
<td><input type="checkbox" name="val[]" value="s" />
SSS</td>
regards,
Bastian
> Hello;
>
> I want to do that:
>
> I have two checkboxes:
> if first one is checked assign the value as a;
> if first one is checked assign the value as s;
> if both of them checked assign th value as as
> and insert the result db;
>
> the html code:
>
> ...
> <tr>
> <td><input type="checkbox" name="val" value="a" />
> AAA</td>
> </tr>
> <tr>
> <td><input type="checkbox" name="val" value="s" />
> SSS</td>
> </tr>
> ...
>
> and the PHP code:
>
> $eval='';
> if(isset($val)){
> if(isset($val[0]) && isset($val[1])) $eval="as";
> if(isset($val[0]) && !isset($val[1])) $eval="a";
> if(!isset($val[0]) && isset($val[1])) $eval="s";
>
> $sql="insert into maillist (ID, postmeth) values
> ('$id_no','$eval')";
> $result=mysql_query($sql);
> if(!$result) echo("ERROR");
> }
>
> I can't understand what is wrong;
>
> Thanks everybody....