?
Solved

How to Dynamically populate a menu item in a search form

Posted on 2006-10-25
5
Medium Priority
?
133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
73Spyder earned 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
What You Need to Know when Searching for a Webhost Provider
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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