I want to reload datatable but only the last record

I want to reload datatable but only the last record

Dream TDream T Posts: 1Questions: 1Answers: 0

// index.php

<!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 table = $('#lic_grid').DataTable( {

                "processing": true,
                "serverSide": true,
                "ajax":{
                    url :"grid-data.php", // json datasource
                    type: "post",  // method  , by default get
                    retrieve:true,

                }

            } );
table.ajax.reload();
        } );

    </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>Dog details </h1></div>
    <div class="container">
        <table id="lic_grid"  cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                <thead>
                    <tr>
                        <th>Sr.No.</th>
  <th>APPLICANT NAME</th>
 <th>DOG NAME</th>
 <th>GENDER</th>


                    </tr>
                </thead>
        </table>
    </div>
</body>

</html>

// grid-data.php

<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 1);

include("dbcon.php");
$requestData= $_REQUEST;

$query=mysqli_query($con,"select * from lic_register ORDER BY app_id DESC");
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData;
$totalFiltered = mysqli_num_rows($query);
$i=1;

while($fetch= mysqli_fetch_array($query))
{
    $result['data'][]=$fetch;

}

 $json_data = array(

        "recordsTotal"    => intval( $totalData ),  
        "recordsFiltered" => intval( $totalFiltered ), 
        "data"            => $result['data']   
        );

echo json_encode($json_data);

<?php > ?>
This discussion has been closed.