Solved

How to Dynamically populate a menu item in a search form

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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