473,382 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

filter the results of a database search based on choices from multiple select list

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.
I tried simply adding multiple to the select form tag.
The reults still filtered according to only one of the options chosen.

This is my select 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>
  15.  
This is the code on my target page -

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";
  2. }
Aug 2 '11 #1
1 1898
Dormilich
8,658 Expert Mod 8TB
to retrieve more than one value, rename the select to "softwareLevel[]" so that the values don’t overwrite each other.

then you have to rewrite your query to allow multiple input. like WHERE titles.level_id IN (1,2,3,4). consult the MySQL Manual for the exact syntax or ask in the MySQL forum.
Aug 3 '11 #2

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

Similar topics

0
by: Stephen Witter | last post by:
I have a multiple select list and I am trying to post to a page where I have no option to use the request.form or vbscript to iterate through the control. The page is a sql server reporting...
29
by: Paul | last post by:
Hi, I'd like to limit the number of selections a user can make in a multiple select listbox. I have a note on the interface to say that only x no. of items should be selected and I check the...
1
by: | last post by:
Hi guys, i have a multiple select list box on my form, and it saves the selections I make into the field just fine., but when i open the form on an existing record, it does not show up the...
3
by: Usenet | last post by:
Hi there, I am quite a novice to MS Access, and I would deeply appreciate help on the following: I have created a list box in a form. I wish for that list box to enter multiple values from table...
3
by: syounger | last post by:
Hi. I have a report in Access 2000 that is based on selection made from a series of interdependent list boxes. The boxes I have right now are Source, Table, Column, Date. The user chooses Source...
1
by: abhishekhs | last post by:
Hi all I have more than one multiple select lists in a page. Something like this <tr> <td> <select NAME="StrainList" ID="StrainList" SIZE="5" multiple="multiple" style="width: 150px"> <?...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
2
by: sathyashrayan | last post by:
Dear group, I have a task where I have to fetch datas from mysql and display it in the multiple select list box. I have fetched the datas and it is getting diplayed correctly in the multiple...
3
by: asivakrupa | last post by:
Hi, I am using a multiple select list box. I use an array to retrieve the values that are selected by the user. <select name="competitor"> When I try to validate the list box if the...
4
beacon
by: beacon | last post by:
Hi everybody, I'm creating a database that will assign standards to departments. My plan is to have a form that will allow the user to use 'Next Record' to go to each standard and have a...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.