mhodgson Posted March 19, 2008 Share Posted March 19, 2008 If I have series of database entries in one field taht contains a list of words, e.g. ID - animal types 1 - cat, dog, elephant, rhino 2 - cat, rhino, frog 3 - dog, frog, tiger I want to be able to search this field by one word, e.g. cat, and only show the records that contain 'cat' in the field. I know how to split the list at each comma and I'm sure it should all go in an array but beyond that I'm a little stumped. Any suggestions would be great. Thanks Link to comment https://forums.phpfreaks.com/topic/96917-searching-several-words-in-one-field/ Share on other sites More sharing options...
effigy Posted March 19, 2008 Share Posted March 19, 2008 FIND_IN_SET Link to comment https://forums.phpfreaks.com/topic/96917-searching-several-words-in-one-field/#findComment-495927 Share on other sites More sharing options...
mhodgson Posted March 19, 2008 Author Share Posted March 19, 2008 Never even new that existed! So simple. Added after to the WHERE part of my sql statement - WHERE FIND_IN_SET($animal, animal_types) variable $animal is the search criterea and animal_types in the field name. Seems to work perfectly. Thanks Link to comment https://forums.phpfreaks.com/topic/96917-searching-several-words-in-one-field/#findComment-495998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.