I have a query string being built and it works fine when I use LIKE but it will not work with NOT LIKE
$sWhere = "";
if ( $_GET['sSearch'] != "" )
{
$aWords = preg_split('/\s+/', $_GET['sSearch']);
$sWhere = "WHERE (";
for ( $j=0 ; $j<count($aWords) ; $j++ )
{
if ( $aWords[$j] != "" )
{
if(substr($aWords[$j], 0, 1) == "!"){
$notString = substr($aWords[$j], 1);
$sWhere .= "(";
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
$sWhere .= $aColumns[$i]." NOT LIKE '%".mysql_real_escape_string( $notString )."%' OR ";
}
}
else{
$sWhere .= "(";
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $aWords[$j] )."%' OR ";
}
}
$sWhere = substr_replace( $sWhere, "", -3 );
$sWhere .= ") AND ";
}
}
$sWhere = substr_replace( $sWhere, "", -4 );
the part of the code that does work is:
if(substr($aWords[$j], 0, 1) == "!"){
$notString = substr($aWords[$j], 1);
$sWhere .= "(";
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
$sWhere .= $aColumns[$i]." NOT LIKE '%".mysql_real_escape_string( $notString )."%' OR ";
}
}
if I remove the "NOT" the query works fine but it does nothing when I add the NOT.
thanks