RE: [PHP-DB] drop down list

From: Date: Thu, 31 Jan 2002 02:12:26 +0000
Subject: RE: [PHP-DB] drop down list
Groups: php.db 
Request: Send a blank email to php-db+get-16337@lists.php.net to get a copy of this message
apologies for answering such an already-over-answered question, but i feel that no-one has given a particularly *good* answer, so i'll add mine to the list. I use this function (as well as a couple others which do similar things for all form elements; // Creates an HTML select box of values. // $options can be one or two dimensional, if one then indexes 0+ are used as values // $misc contains any key/value pairs you want added to the tag as attributes, such // as class, style or "multiple" attributes. function display_select($name, $options, $value = 0, $misc = "unset") { $select = "<select"; if (strlen($name)) $select .= " name=\"" . $name . "\""; if (is_array($misc)) while (list($id, $val) = each($misc)) $select .= " " . $id . "=\"" . $val . "\""; $select .= ">"; if (is_array($options)) { while (list($id, $val) = each($options)) { $select .= "\n<option"; $select .= " value=\"" . $id . "\""; if (strcmp($id, $value)) $select .= ">"; else $select .= " selected>"; $select .= htmlspecialchars($val) . "</option>"; } } $select .= "\n</select>"; return $select; } // -----Original Message----- // From: B.J.Rumsey [mailto:webmaster@musicsearch.ath.cx] // Sent: Wednesday, 30 January 2002 2:30 PM // To: php-db // Subject: [PHP-DB] drop down list // // // I have two fields artist_id, artist. How do I put the // contents of "artist" into a dropdown list. // // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net // For additional commands, e-mail: php-db-help@lists.php.net // To contact the list administrators, e-mail: // php-list-admin@lists.php.net //

« previous php.db (#16337) next »