Solved

How to Dynamically populate a menu item in a search form

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
What You Need to Know when Searching for a Webhost Provider

733 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