Re: option selected
| From: | Tjoumaidis Tasos | Date: | Mon, 25 Nov 2002 12:00:43 +0000 |
| Subject: | Re: option selected | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23648@lists.php.net to get a copy of this message | ||
Hope it helps a bit
Mike Karthauser wrote:
I'm using the contents of a table to print an option list in another form to allow me to cross reference the tables in my data. <? $result = mysql_query("SELECT * FROM category",$db); printf("<select name=\"catcode\">\n"); while ($myrow = mysql_fetch_array($result)) {if ($valuefromdatabase == %s ) {
printf("<option value=\"%s\" selected>%s</option>\n", $myrow["catcode"], $myrow["title"]); }else { the above without selected }
} printf("</select>\n"); ?> Once i have selected from the drop box the variable is submitted back to my table and saved. When re-edit the data - the record already has a value for catcode which i want to reflect within the drop box - in html it would be the addition of selected="selected" within the <option>. Are there any recommended methods of doing this?