Jump to content

Help please


Lagreca

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.