Re: Display in drop-down box
| From: | Joe Van Meer | Date: | Sat, 02 Mar 2002 13:15:00 +0000 |
| Subject: | Re: Display in drop-down box | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17414@lists.php.net to get a copy of this message | ||
Hi there:)
I use odbc so you'll have to change your functions if you're using mysql
//connect to db
$connectionToDB = odbc_connect("cdconsultant", "joecon", "joecon");
//create query statement
$sqlr = "SELECT DISTINCT category FROM CONSULTANT ORDER BY category" ;
//execute the sql statement (query) on the connection made
$resultset = odbc_do($connectionToDB, $sqlr);
print "<form name='myform' method='get'
action='processingpage.php'><select
name='category'>";
//loop through the category field and dump into select box
while(odbc_fetch_row($resultset)){
$category = odbc_result($resultset,1);
print "<option value='$category'>$category</option>";
}
print "</select><font face='Verdana, Arial, Helvetica, sans-serif'
size='2'
color='#663399'>Category</font>";
print "<input type='submit' name='Submit3'
value='Search'>";
print "</form>";
// close the connection
odbc_close($connectionToDB);
Hope this helps, Joe :)
Alvin Ang <alvinacs@singnet.com.sg> wrote in message
news:MABBLODPHAGBDAGADMHLCEOKCGAA.alvinacs@singnet.com.sg...
> 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
>