navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

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

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

 

How to display results matching a comma delimited list variable...help please!

 
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 >> How to display results matching a comma delimited list variable...help please!
Page: [1]
 
jonance

 

Posts: 298
From: Louisville KY USA
Status: offline

 
How to display results matching a comma delimited list ... - 1/16/2008 16:07:16   
Hi,

I really need some help on this as i'm wrapping up a website for a client. I have a backend set up so that they can divide a city up into different sections. For each section they choose to divide it up into, they are to add the zip codes that are contained in that area. They are to enter them separated by a comma like so:

40207, 40208, 40209

That comma delimited list is saved into a database field...now when a user searches a particular section, the zip codes are sent as a variable (Expr1000), however i cannot get it to produce any results. I am using the code below. If there is just one zip it works but any more than that it does not return results. In the above example it should return all listings for all 3 zips. Can anyone help me? Thanks in advance!


SELECT * FROM listings WHERE (zip LIKE '%::Expr1000::%' AND activated =  'yes') ORDER BY type ASC,realname ASC



< Message edited by jonance -- 1/16/2008 16:21:03 >
Spooky

 

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

 
RE: How to display results matching a comma delimited l... - 1/16/2008 16:34:59   
The user would have to enter "40207, 40208, 40209" and the field would need to contain that exact value?
What if the user entered "40208, 40207, 40209" ?

Just to be clear, you are saying if a user enters "40208" it will return results? that would be correct.
As above though, for an accurate match - the zips and spaces would need to be exactly correct.

To get the result of each zip, you would need to split the user input (or use separate text boxes)

eg - after splitting you would be looking at more than one variable
SELECT * FROM listings WHERE (zip LIKE '%"&Expr1000&"%' OR zip LIKE '%"&Expr1001&"%' AND activated = 'yes')






_____________________________

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

§þ:)


(in reply to jonance)
jonance

 

Posts: 298
From: Louisville KY USA
Status: offline

 
RE: How to display results matching a comma delimited l... - 1/16/2008 17:04:53   
Thanks for the reply Spooky...

Yes, you pretty much got it. But it isn't the user entering it per say. It is the site owner. They will assign an area, say, West Louisville...the zip codes. So West Louisville could have the value for the zip code field like 40208, 40209, 40210 or something like that. When a user chooses West Louisville from a drop down, it will actually send the zips over as i typed them above as a variable. So i need the records that have a zip code that matches any of those to show up in the results. Of course it works for just one as that is normal...but i'm not sure how to handle the sql statement so it splits those up at the comma and space and makes them like an OR statement. Hopefully you see what i'm getting at..i just don't know how to execute it.

Thanks
John

(in reply to Spooky)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> How to display results matching a comma delimited list variable...help please!
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