note 100656 modified in control-structures.else by danbrown
| From: | danbrown@php.net | Date: | Thu, 28 Oct 2010 16:30:58 +0000 |
| Subject: | note 100656 modified in control-structures.else by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173567@lists.php.net to get a copy of this message | ||
You can use the if to make a Yes/No field, verify if the statement is real or not and show the
correct option checked.
<?php if($variable == 'S') {?>
<input name="blah" type="radio" value="Y"
checked="checked"> Yes
<input name="blah" type="radio" value="N"> No
<?php } else {?>
<input name="blah" type="radio" value="Y"> Yes
<input name="blah" type="radio" value="N"
checked="checked"> No
<?php }?>
--was--
You can use the if to make a Yes/No field, verify if the statement is real or not and show the
correct option checked.
<? if($variable == 'S') {?>
<input name="blah" type="radio" value="Y"
checked="checked"> Yes
<input name="blah" type="radio" value="N"> No
<?} else {?>
<input name="blah" type="radio" value="Y"> Yes
<input name="blah" type="radio" value="N"
checked="checked"> No
<?}?>
http://php.net/manual/en/control-structures.else.php