By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

AutoSuggest Results Filtered via Drop Down

P: 2
http://www.etcontrol.com/autosuggest/autosuggest.php

I am trying to add a drop down to filter the results. Is there a way to do that? Or just point me in the right direction. Thanks!!!

Expand|Select|Wrap|Line Numbers
  1. <?php include('xxxx.php');   
  2.  
  3.     $SQL_FROM = 'directory';        
  4.     $searcht = $_GET['t'];
  5.     $SQL_WHERE = 'City';
  6.  
  7.     if ($searcht=='Zip')
  8.     $SQL_WHERE = 'Zip';
  9.  
  10.     if ($searcht=='Manuf')
  11.     $SQL_WHERE = 'Manuf';
  12.  
  13. ?>
  14. <?php
  15.             $searchq        =    strip_tags($_GET['q']);        
  16.             $getRecord_sql    =     'SELECT * FROM '.$SQL_FROM.' WHERE '.$SQL_WHERE.' LIKE "'.$searchq.'%"';
  17.             $getRecord        =      mysql_query($getRecord_sql);
  18.             if(strlen($searchq)>0){
  19.  
  20.             echo '<ul>';
  21.             while ($row = mysql_fetch_array($getRecord)) {?>
  22.  
  23.     <img src="/images/icon.png" border="0" />
  24.     <?php echo $row['City'];?> 
  25.     <?php echo $row['Zip'];?> <img src="/autosuggest/lib/white_arrow.png" width="12" height="12" /> 
  26.     <?php echo $row['CoName'];?> <img src="/autosuggest/lib/phone.png" width="12" height="12" />
  27.     <?php echo $row['Phone'];?> 
  28.     <?php echo $row['DLR']? '<img src="dealer.gif" align="middle">' : '';?>
  29.     <?php echo $row['RNT']? '<img src="rental.gif" align="middle">' : '';?>
  30.     <?php echo $row['MFG']? '<img src="manuf.gif" align="middle">' : '';?>
  31.     <?php echo $row['SVC']? '<img src="service.gif" align="middle">' : '';?>
  32.     <?php echo $row['SUP']? '<img src="supplier.gif" align="middle">' : '';?>
  33.     <?php echo $row['PK']? '<img src="park.gif" align="middle">' : '';?>
  34.     <?php echo $row['NDR']? '<img src="national.gif" align="middle">' : '';?><br /></a><?php } echo '</ul>';
  35.         ?>
  36. <?php } ?>
This code is from Woork Blogspot
Jul 8 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Where would you want the drop down? What options would you have in the drop down?
Jul 9 '08 #2

P: 2
Thanks for the response! Researching online for a solution I come to a conclusion to use a onChange function (JS) within the option value that will be called. My hang up is how to start it. Basically, the AutoSuggest filters Cities from the database based onKeypress function and shows results ... what I am trying to do is filter the results only to show RV Service, RV Parks, and etc. ... each CITY line item in the database have option values 'SVC' for RV Service, or 'PK' for RV Parks. So when AUSTIN is typed in ... it will show every type of service in that City, but I would like to have a drop down to filter just RV Service for that CITY? Sorry I'm not a programmer so I trying to explain it the best I can. Any help is appreciated! As far as, the location of the additional code ... I really don't know. I assume it would be placed with the form entry (autosuggest.php), or the PHP page (search.php) that initiates the MySQL searches (the code I cut/pasted in my last post).

Thanks!

www.etcontrol.com/search_page.php
Jul 13 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Use checkboxes for the services. If the checkbox for a particular service is checked, display that entry.
Jul 14 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.