Jump to content

[SOLVED] Help with my php search query


cuprasteve

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.