MDanz Posted May 21, 2011 Share Posted May 21, 2011 i have imploded the array '$scope'. i want to put the results into a multiple where clause. The problem is how do i implement OR into the WHERE clause? $scopetwo = implode("keywords=",$scope); $getresults=mysql_query("SELECT * FROM message WHERE '$scopetwo' ORDER BY posted ASC",$this->connect); Link to comment https://forums.phpfreaks.com/topic/237027-where-clause-help/ Share on other sites More sharing options...
Pikachu2000 Posted May 21, 2011 Share Posted May 21, 2011 Instead of using a string or ORs, you can use IN(). Note the change to the glue in the implode() as well . . . $scopetwo = implode("', '", $scope); $getresults=mysql_query("SELECT * FROM message WHERE keywords IN ('$scopetwo') ORDER BY posted ASC",$this->connect); Link to comment https://forums.phpfreaks.com/topic/237027-where-clause-help/#findComment-1218314 Share on other sites More sharing options...
MDanz Posted May 21, 2011 Author Share Posted May 21, 2011 nvm Link to comment https://forums.phpfreaks.com/topic/237027-where-clause-help/#findComment-1218318 Share on other sites More sharing options...
Pikachu2000 Posted May 21, 2011 Share Posted May 21, 2011 You may want to array_merge() the arrays before using implode. Then you can format the whole thing in one shot. Untested, but this should work. $merged_scopes = array_merge( $scope, $scopepre ); $scopefinal = implode( "', '" ,$merged_scopes ); Link to comment https://forums.phpfreaks.com/topic/237027-where-clause-help/#findComment-1218320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.