I am following this [tutorial](https://coderexample.com/datatable-demo-server-side-in-phpmysql-and-ajax/) to apply datatables server side processing in PHP, MSSQL and AJAX.

I adjusted the mentioned code to my requirements. Here is my index page

```
<!DOCTYPE html>
<html>
    <title>Datatable</title>
    <head>
        <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
        <script type="text/javascript" language="javascript" src="js/jquery.js"></script>
        <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
        <script type="text/javascript" language="javascript" >
            $(document).ready(function() {
                var dataTable = $('#grid').DataTable( {
                    "processing": true,
                    "serverSide": true,
                    "ajax":{
                        url :"grid-data.php",
                        type: "post", 
                        error: function(){
                            $(".grid-error").html("");
                            $("#grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
                            $("#grid_processing").css("display","none");

                        }
                    }
                } );
            } );
        </script>
        <style>
            div.container {
                margin: 0 auto;
                max-width:760px;
            }
            div.header {
                margin: 100px auto;
                line-height:30px;
                max-width:760px;
            }
            body {
                background: #f7f7f7;
                color: #333;
                font: 90%/1.45em "Helvetica Neue",HelveticaNeue,Verdana,Arial,Helvetica,sans-serif;
            }
        </style>
    </head>
    <body>
        <div class="header"><h1>DataTable demo</h1></div>
        <div class="container">
            <table id="grid"  cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                    <thead>
                        <tr>
                            <th>Country</th>
                            <th>Territory</th>
                            <th>Market</th>
                        </tr>
                    </thead>
            </table>
        </div>
    </body>
</html>

```

and here is grid-data.php 

```
<?php

$servername = "******";
$username = "******";
$password = "******";
$dbname = "mydatabase";

$dbDB = new PDO("odbc:Driver=ODBC Driver 13 for SQL Server;Server=******,1456;Database=mydatabase;Port=1456", $username, $password);
$requestData= $_REQUEST;

$columns = array( 
    0 =>'Country', 
    1 => 'Territory',
    2=> 'Market' );

$sql = "SELECT Country, Territory, Market ";
$sql.=" FROM mydatabase.mytable";

$nRows = $dbDB->query("SELECT count(*) from mydatabase.mytable")->fetchColumn(); 
$totalData = $nRows;
$totalFiltered = $totalData;

$sql = "SELECT Country, Territory, Market ";
$sql.=" FROM mydatabase.mytable WHERE 1=1";
if( !empty($requestData['search']['value']) ) {
    $sql.=" AND ( Country LIKE '".$requestData['search']['value']."%' ";    
    $sql.=" OR Territory LIKE '".$requestData['search']['value']."%' ";
    $sql.=" OR Market LIKE '".$requestData['search']['value']."%' )";
}

$nRowsSearch = $dbDB->query($sql)->fetchColumn(); 
$totalFiltered = $nRowsSearch;

$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."  LIMIT ".$requestData['start']." ,".$requestData['length']."   ";

$data = array();
$query = 'SELECT Country, Territory, Market FROM mydatabase.mytable WHERE 1=1';

foreach ($dbDB->query($query) as $row) {
    $nestedData=array(); 
    $nestedData[] = $row["Country"];
    $nestedData[] = $row["Territory"];
    $nestedData[] = $row["Market"];

    $data[] = $nestedData;

} 

$json_data = array(
            "draw"            => intval( $requestData['draw'] ),   
            "recordsTotal"    => intval( $totalData ),  
            "recordsFiltered" => intval( $totalFiltered ), 
            "data"            => $data  
            );

echo json_encode($json_data); 

?>

```

The data is loaded correctly in my table but all the features like search and changing the length and ordering.. are not working.

Can you please advise me what I am missing in my grid-data.php ? Thank you very much for your suggestions.