I'm toying around with a script to allow users to search for other users based on certain criteria contained in their profiles.

Anyhow, some of the attributes on the user profiles are things like what they are seeking like dating, someone to talk to, etc. I decided to serialize the array and store the list in the db that way which results in something like: a:6:{s:7:"friends";s:1:"1";s:8:"hang_out";s:1:"1";s:6:"dating";s:1:"1";s:4:"talk";s:1:"1";s:8:"intimate";s:1:"0";s:5:"other";s:1:"0";} The entire list is there (both checked and unchecked values) and I can tell what was checked but how do I perform a search against this data? I tried several things that really didn't work out so well.

For example if a user who is searching chooses just one or two of the options I need the query to find only the users who have also checked that option (denoted by "1").

I tried so serialize the search options and use IN in the query but that didn't work out the way that I was expecting.

Is there any easy way to do this or should I be taking an entirely different approach to saving and searching the data?

8 Years
Discussion Span
Last Post by CFROG

I settled for an alternate way to go about this. Thanks anyhow.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.