Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Using an Array to filter a recordset
Old 05-21-2006, 11:35 AM Using an Array to filter a recordset
Junior Talker

Posts: 3
Trades: 0
I have a form on a page with some checkboxes (the name of each checkbox is the same). The checkboxes are retrieved from a database (Access & ASP) so there might be one or many checkboxes depending on which page the user is on. The value of the checkbox is the ID of the record.

I want the user to select whichever checkboxes they like and on the next page I want to use their selection as the WHERE clause or filter to retrieve data from another table where the ID number being passed is equal to a field in the table.

So currently someone clicks two from a possible four checkboxes and the ID numbers of the two they selected are 16 and 18. On the next page I can retrieve their selection via Request.Querystring and I get an array of 16,18. I can split that array so then I've got ID(0) = 16 and ID(1) = 18 but how do I retrieve from the database the two records whose ID is 16 and 18.

I'm not too good at writing my own recordsets I usually use the Dreamweaver recordset so I'm only used to filtering my recordsets by a single passed variable or cookie.

Sorry if I've not explained that too well, basically i need to say to the database return all records where the ID is equal to X, Y and Z (where XYZ are in an array and there might be just one ID (i.e. X) or there might be many.

Many thanks.
scimitar1971 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-21-2006, 12:36 PM Re: Using an Array to filter a recordset
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you don't need to do the split.

Just use the IN(csv_string) in your WHERE clause


http://www.w3schools.com/sql/sql_in.asp
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Using an Array to filter a recordset
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09312 seconds with 12 queries