jaxdevil Posted May 24, 2008 Share Posted May 24, 2008 I am trying to make a search query that can display all the items in the database that match a phrase that is between two '|' symbols. I have a field in my database that is called 'cats' for categories, and since everything has multiple categories I seperate the different ones from each other with a '|' symbol. Now I am trying to pull them up based on that using the following code and by sending the data to the page. I can't get it to work. Any ideas? By the way I use the same code and it works when there is just a single thing to search for in the cats field, not multiples with a delimeter and I just do a plain search like %cat1%. Here is an example of whats in the `cats` field now: consumer electronics|videogame console software|ps3 games And here is the query string: $result = mysql_query("SELECT count(*) FROM products WHERE `cats` LIKE '%|$cat1|%' OR `cats` LIKE '%|$cat2|%' OR `cats` LIKE '%|$cat3|%'") or die(mysql_error I appreciate any help guys Quote Link to comment Share on other sites More sharing options...
jaxdevil Posted May 24, 2008 Author Share Posted May 24, 2008 Duh! My bad. Consumer electronics was that I was testing the search with, and it only has the delimiter AFTER the name, not before. Dooh (as homer would say) Ah well, third times the charm Thank anyways people, hope this helps someone looking for the same answer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.