Re: selected value from database
| From: | Terry Romine | Date: | Sat, 19 Apr 2003 12:19:52 +0000 |
| Subject: | Re: selected value from database | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27181@lists.php.net to get a copy of this message | ||
Better yet:
<option value="author" <? if($level=="author") echo "selected"; ?>
Author</option> for each option value.Terry On Saturday, April 19, 2003, at 12:05 AM, olinux wrote:
try this - $level is the value retrieved from the db $level_options = '<option value="admin">Admin</option> <option value="author">Author</option> <option value="contributor">Contributor</option>'; $level_options = str_replace("\"$level\">", "\"$level\" selected>", $level_options); olinux --- Peter Gumbrell <peter@orillia.net> wrote:In an update form, I have a select list with only 3 values: admin, author and contributor. How do I have the value currently held in the database be the one which is selected? Here is the code that I have so far; print "<td> Level: <select name=\"level\" value=\"$level\"><option value=\"admin\">Admin</option>\n"; print "<option value=\"author\">Author</option><option