option selected

From: Date: Mon, 25 Nov 2002 11:04:02 +0000
Subject: option selected
Groups: php.db 
Request: Send a blank email to php-db+get-23645@lists.php.net to get a copy of this message
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)) { printf("<option value=\"%s\">%s</option>\n", $myrow["catcode"], $myrow["title"]); } 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? -- Mike Karthauser Managing Director - Brightstorm Ltd Email >> mikek@brightstorm.co.uk Web >> http://www.brightstorm.co.uk Tel >> 0117 9426653 (office) 07939 252144 (mobile) Snailmail >> Unit 8, 14 King Square, Bristol BS2 8JJ

« previous php.db (#23645) next »