Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter To Dropdown

Status
Not open for further replies.

finkelman

Programmer
Mar 17, 2002
5
0
0
US
Hi,

I would like setup a filter that will take all the States found in the results and create a dropdown menu. Here is what my SQL statment looks like.

<% 'RETRIVE CURRENT VALUES FROM THE DATABASE

store_id = 10

sql_Select_customers = &quot;SELECT first_name, last_name, Address1, Address2, State FROM store_customers WHERE Store_id=&quot;&Store_id
rs_Store.open sql_Select_customers,conn_store,1,1
rs_Store.Close

%>

How can I create a dropdown menu based on all the states found in the search, while of course taking out duplicates.

Bellow is an example of how my table might look like, and what the results will be.

Table: store_customers
Joe1|Smith1|1011 11st|1st Floor|NY
Joe2|Smith2|1012 12st|2st Floor|NJ
Joe3|Smith3|1013 13st|3st Floor|CA
Joe4|Smith4|1014 14st|4st Floor|NY
Joe5|Smith5|1015 15st|5st Floor|NJ
Joe6|Smith6|1016 16st|6st Floor|PA

This would be the dropdown results.

<select name=state>
<option>NY
<option>NJ
<option>CA
<option>PA
</select>


Thanks
 
You need to slip DISTINCT in there somewhere. If you are only using distinct states - can't tell from your demo, but you ould jut grab them then.

&quot;SELECT DISTINCT State FROM store_customers WHERE Store_id='&quot;& Store_id & &quot;'&quot;

or I suppose a filter may come in handy

I have only ever got the * wildcard to work, just as an aside.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top