Solved

How to Dynamically populate a menu item in a search form

Posted on 2006-10-25
5
126 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

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help Fix A 403 error 13 103
AWS Advice on using WHM/cPanel 1 69
spamming  on Hosted svrs? 6 73
Help with a redirect in web.config file 8 25
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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A simple description of email encryption using a secure portal service. This is one of the choices offered by The Email Laundry for email encryption. The other choices are pdf encryption which creates an encrypted pdf of your email and any attachmen…

911 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

23 Experts available now in Live!

Get 1:1 Help Now