Mam problem z wyszukiwarką. Może ktoś pomoże z WAS.
Problem polega na tym iż wpisuje jedno słowo to wyszukuje bez problemu, lecz jak już wpisze dwa słowa to już nic nie pokazuje. Mój kod wygląda tak :
function getRecords($params) {
$rp = isset($params['rowCount']) ?
$params['rowCount'] : 10;
if (isset($params['current'])) { $page = $params['current']; } else { $page=1; }; $start_from = ($page-1) * $rp;
$sql = $sqlRec = $sqlTot = $where = '';
if( !empty($params['searchPhrase']) ) { $where .=" WHERE ";
$where .=" ( employee_name LIKE '%".$params['searchPhrase']."%' ";
$where .=" OR employee_salary LIKE '".$params['searchPhrase']."%' ";
$where .=" OR employee_age LIKE '".$params['searchPhrase']."%' ";
$where .=" OR employee_magazyn LIKE '".$params['searchPhrase']."%' )";
}
if( !empty($params['sort']) ) { $where .=" ORDER By ".key($params['sort']) .' '.current($params['sort'])." "; }
// getting total number records without any search
$sql = "SELECT * FROM `employee` ";
$sqlTot .= $sql;
$sqlRec .= $sql;
//concatenate search sql if value exist
if(isset($where) && $where != '') {
$sqlTot .= $where;
$sqlRec .= $where;
}
if ($rp!=-1)
$sqlRec .= " LIMIT ". $start_from .",".$rp;
$qtot = mysqli_query
($this->conn, $sqlTot) or
die("error to fetch tot employees data"); $queryRecords = mysqli_query
($this->conn, $sqlRec) or
die("error to fetch employees data");
while( $row = mysqli_fetch_assoc($queryRecords) ) {
$data[] = $row;
}
"current" => intval($params['current']), "rowCount" => 10,
"total" => intval($qtot->num_rows), "rows" => $data // total data array
);
return $json_data;
}
Próbowałem już tez :
function getRecords($params) {
$rp = isset($params['rowCount']) ?
$params['rowCount'] : 10;
if (isset($params['current'])) { $page = $params['current']; } else { $page=1; }; $start_from = ($page-1) * $rp;
$sql = $sqlRec = $sqlTot = $where = '';
if( !empty($params['searchPhrase']) ) { $where .=" WHERE ";
$where .="MATCH ( employee_name, employee_salary) AGAINST ('%".$params['searchPhrase']."%') ";
}
if( !empty($params['sort']) ) { $where .=" ORDER By ".key($params['sort']) .' '.current($params['sort'])." "; }
// getting total number records without any search
$sql = "SELECT * FROM `employee` ";
$sqlTot .= $sql;
$sqlRec .= $sql;
//concatenate search sql if value exist
if(isset($where) && $where != '') {
$sqlTot .= $where;
$sqlRec .= $where;
}
if ($rp!=-1)
$sqlRec .= " LIMIT ". $start_from .",".$rp;
$qtot = mysqli_query
($this->conn, $sqlTot) or
die("error to fetch tot employees data"); $queryRecords = mysqli_query
($this->conn, $sqlRec) or
die("error to fetch employees data");
while( $row = mysqli_fetch_assoc($queryRecords) ) {
$data[] = $row;
}
"current" => intval($params['current']), "rowCount" => 10,
"total" => intval($qtot->num_rows), "rows" => $data // total data array
);
return $json_data;
}
emplayee_name i employee_salary mam ustawione jako full text.
Pomożcie proszę.
Widze ze forum bardzo pomocne :(ehh....