cuprasteve Posted October 23, 2007 Share Posted October 23, 2007 Hi all, hoping you can help, at the moment I have this that searchs the db for a string $words = split(" ", $s); $count = count(explode(" ", $s)); $c='0'; while ($c < $count) { $or = $or . "OR " . $where . " LIKE '%" . $words[$c] . "%' "; $c++; } $sql = "SELECT p.pic_id, p.pic_title, p.pic_desc, p.pic_user_id, p.pic_username, p.pic_time, p.pic_cat_id, p.pic_approval, p.pic_file_name, p.pic_thumbnail, c.cat_id, c.cat_title, c.cat_user_id FROM " . ALBUM_TABLE . ' AS p,' . ALBUM_CAT_TABLE . " AS c WHERE p.pic_approval = 1 AND " . $where . " LIKE '%" . $s . "%' $or AND p.pic_cat_id = c.cat_id AND c.cat_view_level <> '3' ORDER BY p.pic_time DESC"; All this works fine apart from if i search for "green seat arosa" it brings up all the stuff with seat | green | arosa in the tags. I need it to bring up results with all words entered into the search, but that can be anywhere in the tags field stored in the DB Link to comment https://forums.phpfreaks.com/topic/74427-solved-help-with-my-php-search-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.