Jump to content

Recommended Posts

I have this problem with Dropular's (http://dropular.net/) search result. This the query I use to receive the DB result when someone for example searches for "red" :

 

$get_results = "SELECT * FROM articles WHERE img LIKE '%".$search_string."%' OR title LIKE '%".$search_string."%' OR pool LIKE '%".$search_string."%' ORDER by date DESC LIMIT ".$num.",50";

 

This works just fine, BUT i want the result only to display this where example TYPE = "image"

 

So, basically, take the result of $get_results, filter it down and look for where TYPE = "image" and keep only these, and remove the others (e.g where TYPE = video or TYPE = link).

 

I hope you understand my question.. very hard to explain.

 

've tried is: $get_results = "SELECT * FROM articles WHERE img LIKE '%".$search_string."%' OR title LIKE '%".$search_string."%' OR pool LIKE '%".$search_string."%' AND type = 'image' ORDER by date DESC LIMIT ".$num.",50";

 

But that does not work.. doesnt seem like multiple LIKE and WHERE works together well.. :'(

 

Best,

Lagreca

Link to comment
https://forums.phpfreaks.com/topic/162209-help-please/
Share on other sites

$get_results = "
SELECT * FROM articles WHERE 
(
     img LIKE '%".$search_string."%' OR
     title LIKE '%".$search_string."%' OR
     pool LIKE '%".$search_string."%'
)
AND type = 'image' ORDER by date DESC LIMIT ".$num.",50";

 

Did you try parentheses

Link to comment
https://forums.phpfreaks.com/topic/162209-help-please/#findComment-856056
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.