George Botley Posted September 24, 2010 Share Posted September 24, 2010 Is it possible to achieve a similar thing to this... SELECT FROM db WHERE value!=$array My example code is this: $browser_hide = array("1" => "YandexBot 0.0 for unknown"); $query = "SELECT * FROM hitlist_hits WHERE month='$month' AND browser!='$browser_hide' ORDER by id DESC"; Thanks Guys. Link to comment https://forums.phpfreaks.com/topic/214316-select-from-db-where-valuearray/ Share on other sites More sharing options...
George Botley Posted September 24, 2010 Author Share Posted September 24, 2010 Any ideas? Link to comment https://forums.phpfreaks.com/topic/214316-select-from-db-where-valuearray/#findComment-1115279 Share on other sites More sharing options...
Psycho Posted September 24, 2010 Share Posted September 24, 2010 Seriously, you waited a whole 12 minutes before bumping your thread. Perhaps the lack of responses is due to the lack of clarity in your request. I *assume* you are wanting to find records where the value does not exist in the values of the array. The query would use the operator "NOT IN" followed by a list of values. $values = "'" . implode("','", $browser_hide) . "'"; $query = "SELECT * FROM hitlist_hits WHERE month='$month' AND browser NOT IN ($values) ORDER by id DESC"; Link to comment https://forums.phpfreaks.com/topic/214316-select-from-db-where-valuearray/#findComment-1115293 Share on other sites More sharing options...
George Botley Posted September 24, 2010 Author Share Posted September 24, 2010 Thank You, I will try that one.. Sorry for my impatience, the project is due shortly, and that was bugging the hell out of me!! I will try to be more clear in future posts. Link to comment https://forums.phpfreaks.com/topic/214316-select-from-db-where-valuearray/#findComment-1115299 Share on other sites More sharing options...
George Botley Posted September 24, 2010 Author Share Posted September 24, 2010 Could you explain what this section does? $values = "'" . implode("','", $browser_hide) . "'"; Link to comment https://forums.phpfreaks.com/topic/214316-select-from-db-where-valuearray/#findComment-1115301 Share on other sites More sharing options...
Psycho Posted September 24, 2010 Share Posted September 24, 2010 Could you explain what this section does? $values = "'" . implode("','", $browser_hide) . "'"; http://php.net/manual/en/function.implode.php echo $values to the page to see what the result is. Link to comment https://forums.phpfreaks.com/topic/214316-select-from-db-where-valuearray/#findComment-1115308 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.