RE: [PHP-DB] Inserting correct value from database into formoption field
| From: | Rudi Benkoviè | Date: | Sat, 28 Apr 2001 22:58:56 +0000 |
| Subject: | RE: [PHP-DB] Inserting correct value from database into formoption field | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-8962@lists.php.net to get a copy of this message | ||
> For example,
>
> <option value="One voyage only"<?php
>
> If ($row['voyage'] == 'One voyage only') { echo ' selected'; }
>
> ?>>One voyage only</option>
Perhaps even a bit more elegant solution:
<?php
$tmp[$row['voyage']] = 'selected';
?>
<option value="One voyage only" <?= $tmp['One voyage only'] ?>>One
voyage
only</option>
<?php
unset ($tmp);
?>
It's just that a bunch of IF's look darn ugly if you have ~25 options.