a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

query with checkbox values

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> query with checkbox values
Page: [1]
 
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
query with checkbox values - 5/1/2006 18:29:21   
Perhaps this has already been covered, but i didnt find specific enough information about my issue.


what is going on is that i have one page that has a form with some check boxes with different values that i want to query my database to see if my field "age" contains one of those value of the check box that was checked (also allow mulitple checked boxes)

a normal record's field "age" would look something like this

20s, 30s, 40s,

my check box values are:

teens
20s
30s
40s
50s
60s

so how do i query the comma diliminated field to see if it has any of those individual values. I got it to work if you just check one box or if the record includes all of the values of the boxes you checked.

can anyone offer specific info on how i would structure my sql to do this. THANKs
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: query with checkbox values - 5/1/2006 18:41:03   
What is your existing SQL string?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to washurjosh)
BeTheBall

 

Posts: 6385
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: query with checkbox values - 5/1/2006 18:43:44   
Assuming you have named each checkbox the same.

SELECT * FROM tblName WHERE Instr('"&Request.Form("checkboxName")&"',age)>0

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to washurjosh)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: query with checkbox values - 5/1/2006 18:51:47   
currently what im using is this:

SELECT * FROM Results WHERE (Sex LIKE '::Sex::%' AND age LIKE '%::age::%') ORDER BY last 




(in reply to BeTheBall)
BeTheBall

 

Posts: 6385
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: query with checkbox values - 5/1/2006 19:47:34   
A little curious why you would use a LIKE argument for sex. Isn't it one or the other? :)

Try this one:

SELECT * FROM Results WHERE (Sex = '::Sex::' AND Instr('"&Request.Form("age")&"',age)>0) ORDER BY last

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to washurjosh)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: query with checkbox values - 5/1/2006 19:57:51   
I dont need the LIKE for the sex your right. I think it was left over from when i was doing something else with the page.

however on to your sql you gave me. I am not sure what the last "age" is for. i mean i get the request.form one which would get the values from the form on the previous page. but should i write it like this????:

SELECT * FROM Results WHERE (Sex = '::Sex::' AND Instr('"&Request.Form("age")&"','::age::')>0) ORDER BY last

(in reply to BeTheBall)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: query with checkbox values - 5/1/2006 20:17:32   
Ok, so i figured a couple of things out and we have almost solved my issue.

1) the reason i used LIKE in the sex sql was because on my form i have three options; MALE, FEMALE, ALL and so my value for ALL=%
2) the second "age" i was talking about i found out why it is there, and thats because instr is a property you can use for sql and thats the structure. (this is where i solved the issue with the check boxes THANKS)
3) now that we are not using LIKE for the "age" field how do i make a checkbox that will display ALL results??


(in reply to washurjosh)
BeTheBall

 

Posts: 6385
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: query with checkbox values - 5/1/2006 20:31:00   
Like this?

<input type="checkbox" name="age" value="teens,20s,30s,40s,50s,60s">

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to washurjosh)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: query with checkbox values - 5/15/2006 3:27:02   
see the problem i find with that is that it only gives me people that have all those types. But what i want is people that may have any combination of types or none at all. Does that make sense?



(in reply to BeTheBall)
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> ASP and Database >> query with checkbox values
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts