I have working search for a created wp_list_table
. But i like to know how I can search in more than one column.
My current my working search setup in a Visitor class
//search something
$searchcol= array(
'visitorCompany',
'visitorName',
'visitorEmail'
);
$search = !empty($_REQUEST["s"]) ? mysql_real_escape_string($_REQUEST["s"]) : '';
//$search = preg_replace( "^$**(.*)**$?#", "*$1*", $_REQUEST["s"] );
if(!empty($_REQUEST["s"])) {$query .= ' WHERE '.$searchcol[1].' LIKE "%'.$search.'%"';}
here I just searching in the visitorName
column, but i like to use the $searchcol
to search in.
A foreach loop
foreach( $searchcol as $col) {
if(!empty($_REQUEST["s"])) {$query .= ' WHERE '.$col.' LIKE "%'.$search.'%"';}
}
didn’t work
Ok i see my WHERE mistake
I made this working solution doesn’t look pretty