Re: Detecting which item too select in a select
| From: | Kyle Jerviss | Date: | Wed, 20 Dec 2000 06:48:55 +0000 |
| Subject: | Re: Detecting which item too select in a select | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31169@lists.php.net to get a copy of this message | ||
Joseph H Blythe wrote:
>
> I have also tried simular code to set the checked value on a pair of radio buttons, as above it
> only will return the last array item, I have read the manual entries for array, list, and each but
> for the life of me can't figure out why this is happening?
>
> --snip--
>
> $ok_to_email = array( 0 => "No", 1 => "Yes");
>
> while (list($key,$val) = each($ok_to_email)) {
> $radio = '<input type="radio" name="emailMe" value="' .
> $key . '"';
> if ( $my_account["EMAILME"] == $key ) {
> $radio .= ' checked';
> }
> $radio .= '>' . $val . "\n";
> }
> $tpl->assign('EMAILME', $radio);
>
> --snip--
>
> Any help would probaly save what is left of my sanity.
Each pass through the while loop clobbers whatever used to be in
$radio. set $radio to a null string outside the loop and use $radio.=
on that first line inside it