Solved

How to Dynamically populate a menu item in a search form

Posted on 2006-10-25
5
125 Views
Last Modified: 2013-12-24
  Ok here's the situation I have thousands of property listings in my database and want to dynamically populate my search form dropdown menu with cities pulled from my database.  The code I wrote below does that, but pulls the city from each row(thousands) so I have multiple duplicates of the same city name in my menu. How can I limit that to one instance of each city name? Hope this makes sense...Thanks!


<cfquery name="myqueryname" datasource="mydatasource">
         SELECT col1, col5, col10, col15, col16
          FROM mytable
          ORDER BY col10 ASC
   </cfquery>


 <select name="col10" id="col10">            
      <option value=""></option>
      <cfoutput query = "myqueryname">
      <option value="#col10#">#col10#</option>            
      </cfoutput>
        </select>



0
Comment
Question by:Bang-O-Matic
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
73Spyder earned 500 total points
ID: 17806574
Have a new query/ or revise the old one

<cfquery name="myquerynameCity" datasource="mydatasource">
         SELECT DISTINCT  col10
          FROM mytable
          ORDER BY col10 ASC
   </cfquery>

<select name="col10" id="col10">          
     <option value=""></option>
     <cfoutput query = "myquerynameCity">
     <option value="#col10#">#col10#</option>          
     </cfoutput>
        </select>
0
 
LVL 9

Expert Comment

by:73Spyder
ID: 17806582
This should cut down on processing time to run the query too.
0
 

Author Comment

by:Bang-O-Matic
ID: 17806760
Thanks!
0
 

Author Comment

by:Bang-O-Matic
ID: 17810711
Thanks again
0
 
LVL 9

Expert Comment

by:73Spyder
ID: 17810720
Glad to have helped
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Script 12 114
Apache SSL and mod_rewrite not working 8 106
Systems talking to each other 5 110
site launch date and last modified date 3 54
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now