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

How to write a query that allows multiple input from a select list

P: 37
I have a select list that allows me to filter the results of a database search.
The user chooses from a dropdown menu then clicks submit.
The target page shows only the records containing what was chosen from the list.
What I would like is to allow the user to choose multiple items from the
list while holding down the ctrl key, then filter the search results based on what was chosen.

Can you tell me how to change the syntax on my target page query so that is allows multiple input.

something like -

WHERE titles.level_id IN (1,2,3,4)

This is the current query
Expand|Select|Wrap|Line Numbers
  1. $query_rsTitles = "SELECT id, title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE titles.level_id = ". GetSQLValueString($_POST['softwareLevel'], "int") ." ORDER BY id ASC";
This is the menu code -

Expand|Select|Wrap|Line Numbers
  1. <select name="softwareLevel[]" id="softwareLevel">
  2.           <?php
  3.   do {  
  4.   ?>
  5.           <option value="<?php echo $row_rs_level['level_id']?>"><?php echo $row_rs_level['level']?></option>
  6.         <?php
  7.   } while ($row_rs_level = mysql_fetch_assoc($rs_level));
  8.     $rows = mysql_num_rows($rs_level);
  9.    if($rows > 0) {
  10.       mysql_data_seek($rs_level, 0);
  11.       $row_rs_level = mysql_fetch_assoc($rs_level);
  12.    }
  13.  ?>
  14.   </select>
Aug 3 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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