Dynamic Drop-down list
| From: | Todd Cary | Date: | Fri, 09 Feb 2001 00:59:35 +0000 |
| Subject: | Dynamic Drop-down list | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-38855@lists.php.net to get a copy of this message | ||
I create a Drop-down from a DB table. All works as expected *except*
the default item (the one showing to the surfer) is the last in the
list. Is there a way I can have the first item show?
Todd
/* Make a drop-down */
function make_dropdown($ddName, $itemList, $first) {
if (count($itemList)) {
echo("<SELECT NAME=" . $ddName . ">");
if ($first) {
echo('<OPTION VALUE="**" SELECTED>' . $first);
};
while (list ($key, $val) = each ($itemList)) {
echo('<OPTION VALUE="' . $key . '" SELECTED>' .
$val);
};
echo("</SELECT>");
};
};
--
Todd Cary
Ariste Software
todd@aristesoftware.com