Re: Inserting correct value from database into form option field

From: Date: Sat, 28 Apr 2001 22:47:29 +0000
Subject: Re: Inserting correct value from database into form option field
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8960@lists.php.net to get a copy of this message
on 4/28/01 1:32 AM, Howard Picken at hpicken@our.net.au wrote: > <tr><td>Which Voyage:</td><td><select name="voyage" > COLS=100 ROWS=1 > value="<?php echo $row["voyage"] ?>"> > > <option value="One voyage only">One voyage only</option> In an HTML <select>, you can't specify the value in the select tag (btw, you can't specify cols or rows either). To specify the item to pick, you must add a " selected" keyword to the appropriate option tag. Typically in PHP, this is done with a series of if statements. For example, <option value="One voyage only"<?php If ($row['voyage'] == 'One voyage only') { echo ' selected'; } ?>>One voyage only</option> Hope that helps, Paul Burney http://paulburney.com/ http://webdevel.burney.ws/

« previous php.db (#8960) next »