php - add where clause to datatables filtering -


hi trying add custom clause in datatables server side processing file. have managed work when page loads after filtering ignores clause , returns results.

code:

$swhere = "where customers_id= ".$customersid; if ( isset($_get['ssearch']) && $_get['ssearch'] != "" ) { $swhere = "where ("; ( $i=0 ; $i<count($acolumns) ; $i++ ) { if ( isset($_get['bsearchable_'.$i]) && $_get['bsearchable_'.$i] == "true" ) { $swhere .= "`".$acolumns[$i]."` '%".mysql_real_escape_string( $_get['ssearch'] )."%' or "; } } $swhere = substr_replace( $swhere, "", -3 ); $swhere .= ')'; } /* individual column filtering */ ( $i=0 ; $i<count($acolumns) ; $i++ ) { if ( isset($_get['bsearchable_'.$i]) && $_get['bsearchable_'.$i] == "true" && $_get['ssearch_'.$i] != '' ) { if ( $swhere == "" ) { $swhere = "where "; } else { $swhere .= " , "; } $swhere .= "`".$acolumns[$i]."` '%".mysql_real_escape_string($_get['ssearch_'.$i])."%' "; } } 

i cannot figure out add other clauses in order work when beign filtered also.

remove first line , add @ end (after if , for):

$swhere .= ($swhere ? ' , ' : ' ') . 'customers_id = ' . $customersid; 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -