Re: selected value from database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 
>
value=\"contributor\">Contributor</option></select></td></tr>\n";
> 
> As you can see, the value taken from the database is
> $level.
> 
> Many thanks,
> 
> Peter Gumbrell
> peter@orillia.net
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux