Database value as selected in combo box!
| From: | Anthony Judd | Date: | Sun, 02 Feb 2003 06:20:03 +0000 |
| Subject: | Database value as selected in combo box! | ||
| Groups: | php.lang | ||
| Request: | Send a blank email to php-lang+get-453@lists.php.net to get a copy of this message | ||
I am trying to display the current database value as SELECTED in a combo
box. Any ideas why this isn't working. (ID is being sent).
Would appreciate any help.
function retrieve_category()
{
$cat = mysql_query("SELECT category_id FROM category");
while ($current_row = mysql_fetch_row($cat))
{
if ($current_row[0] == $id)
{
printf("<option selected>%s</option>\n",$current_row[0]);
}
else
{
printf("<option>%s</option>\n",$current_row[0]);
}
}
}