Jump to content

Why wont this work?


dominod

Recommended Posts

Hi !

 

I am trying this code:

   $query = "SELECT * FROM `table` WHERE name LIKE '%$keyword%' AND blocked != '%no%' ORDER BY hits DESC LIMIT 10 ";

 

The 'blocked' row has the following value: "se dk no uk es"

 

Now, what I want it to do is to NOT include that row IF it finds "no" in the blocked row... The problem is that it dont block it :/ It works if I dont use wildcard characters and the 'blocked' row = 'no' but I want to have multiple values in that row...

 

 

Thanks in advance :)

 

Link to comment
https://forums.phpfreaks.com/topic/212882-why-wont-this-work/
Share on other sites

maybe you can try

 

$query = "SELECT * FROM `table` WHERE name LIKE '%$keyword%' AND LOCATE(' no ', blocked) = 0 ORDER BY hits DESC LIMIT 10 "

 

if the 'no' is always in the middle of the string... wouldn't work if is in the borders.  assuming that 'no' will be no part of other part of the string just use LOCATE('no', blocked)

Link to comment
https://forums.phpfreaks.com/topic/212882-why-wont-this-work/#findComment-1108777
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.