Re: Drop down lists

From: Date: Sun, 18 Jan 2004 07:06:21 +0000
Subject: Re: Drop down lists
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-174959@lists.php.net to get a copy of this message
Yes it's possible. I believe there's a way to do it with PEAR also but I've never done it that way before. I always do: --- <SELECT name = "username"> <OPTION selected>--- Please Choose a Username ---</OPTION> <?php // retrieve a list of usernames from the DB $results = mysql_query("SELECT userID, username FROM users") or die ("could not perform requested query"); // make sure we got a list of usernames back if (mysql_num_rows($results) != 0) { // process the returned results for ($i = 0; $i < mysql_num_rows($results); $i++) { // get a row of results back from the result set $row = mysql_fetch_array($results); // construct the dropdown menu item echo "<OPTION value = \"" . $row["userID"] . "\">" . $row["username"] . "</OPTION>"; } } else { echo "No names in the database"; } ?> </SELECT> Of course you need to embed this within a <FORM> tag. -Pete --- On Sun, 2004-01-18 at 01:18, BigMark wrote: > Is it possible to have usernames from my db populated into a drop down > list. > If so What and where does it go to make it all work, ive tried everything i > know > ( which is not much by the way). > > Mark -- perl -e 'print pack("H*", "70766572746573406E79632E72722E636F6D0A")'

Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
« previous php.general (#174959) next »