datatables + serverside processing + search filtering
<p>I am following this tutorial:<br>
<a href="http://coderexample.com/datatable-demo-server-side-in-phpmysql-and-ajax/" rel="nofollow">http://coderexample.com/datatable-demo-server-side-in-phpmysql-and-ajax/</a></p>

<p>and here is the demo: <br>
<a href="http://coderexample.com/demo/datatable-demo-server-side-in-phpmysql-and-ajax/" rel="nofollow">http://coderexample.com/demo/datatable-demo-server-side-in-phpmysql-and-ajax/</a></p>

<p>If i search for <code>ou</code> in the search input i get <code>No matching records found</code> but what I would like returned is this row <code>Airi Satou</code> at least. </p>

<p><a href="https://github.com/coderexample/datatable_example/blob/master/demo1/employee-grid-data.php" rel="nofollow">this</a> is the code that i have to change, I think, as I have to do the search server side.</p>

<pre><code>&lt;?php
/* Database connection start */
$servername = "localhost";
$username = "root";
$password = "Password1";
$dbname = "test";

$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());

/* Database connection end */


// storing  request (ie, get/post) global array to a variable  
$requestData= $_REQUEST;


$columns = array( 
// datatable column index  =&gt; database column name
    0 =&gt;'employee_name', 
    1 =&gt; 'employee_salary',
    2=&gt; 'employee_age'
);

// getting total number records without any search
$sql = "SELECT employee_name, employee_salary, employee_age ";
$sql.=" FROM employee";
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData;  // when there is no search parameter then total number rows = total number filtered rows.


if( !empty($requestData['search']['value']) ) {
    // if there is a search parameter
    $sql = "SELECT employee_name, employee_salary, employee_age ";
    $sql.=" FROM employee";
    $sql.=" WHERE employee_name LIKE '".$requestData['search']['value']."%' ";    // $requestData['search']['value'] contains search parameter
    $sql.=" OR employee_salary LIKE '".$requestData['search']['value']."%' ";
    $sql.=" OR employee_age LIKE '".$requestData['search']['value']."%' ";
    $query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
    $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result without limit in the query 

    $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."   LIMIT ".$requestData['start']." ,".$requestData['length']."   "; // $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc , $requestData['start'] contains start row number ,$requestData['length'] contains limit length.
    $query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees"); // again run query with limit

} else {    

    $sql = "SELECT employee_name, employee_salary, employee_age ";
    $sql.=" FROM employee";
    $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."   LIMIT ".$requestData['start']." ,".$requestData['length']."   ";
    $query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");

}

$data = array();
while( $row=mysqli_fetch_array($query) ) {  // preparing an array
    $nestedData=array(); 

    $nestedData[] = $row["employee_name"];
    $nestedData[] = $row["employee_salary"];
    $nestedData[] = $row["employee_age"];

    $data[] = $nestedData;
}



$json_data = array(
            "draw"            =&gt; intval( $requestData['draw'] ),   // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. 
            "recordsTotal"    =&gt; intval( $totalData ),  // total number of records
            "recordsFiltered" =&gt; intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
            "data"            =&gt; $data   // total data array
            );

echo json_encode($json_data);  // send data as json format

?&gt;
</code></pre>

<p>Am I right to say that this is the code I have to change? <br>
If so, can anyone advise what I have to do? <br>
I understand this is alot to ask but would appreciate the guidance!</p>