RE: [PHP-DB] Display in drop-down box
| From: | Ryan Marrs | Date: | Fri, 01 Mar 2002 19:15:49 +0000 |
| Subject: | RE: [PHP-DB] Display in drop-down box | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17397@lists.php.net to get a copy of this message | ||
Let me give this a shot :P
<?
Mysql_connect("sqlserver","user","pass");
Mysql_select_db("db");
$resultset = mysql_query("select DISTINCT identifier, displayname from
table");
for($i=1;$i<=mysql_num_rows($resultset);$i++)
{
$object = mysql_fetch_object($resultset);
$identifier = $object -> identifier;
$displayname = $object -> displayname;
print "<option value=\"$identifier\">$displayname</option>";
}
?>
I do believe that should do it. Correct me if I missed anything.
Ryan
-----Original Message-----
From: Leotta, Natalie (NCI/IMS) [mailto:LeottaN@ims.nci.nih.gov]
Sent: Friday, March 01, 2002 2:10 PM
To: PHP
Subject: RE: [PHP-DB] Display in drop-down box
Try doing a select distinct on that field and then loop through the results,
adding each one to your drop-down box as you go.
I don't have the exact code anymore because we stopped doing it that way,
but that's the basic idea of how to go about it.
I hope it helps!
-Natalie
> -----Original Message-----
> From: Alvin Ang [SMTP:alvinacs@singnet.com.sg]
> Sent: Friday, March 01, 2002 2:07 PM
> To: PHP
> Subject: [PHP-DB] Display in drop-down box
>
> Hi there,
>
> I was wondering if anyone would be kind enough to show me how to select a
> field from a table in mysql and display it in a drop-down combo box?
>
> I am trying to show my users a list of all the parts from a table so that
> they can edit or delete it.
>
> Thanks!
>
> Alvin
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php