server side pagination in jquery datatable
<p>I am having displaying datas. Because it contains more than 1000 rows of data. I want to have a server side pagination instead of what jquery datatable offers. As i have noticed, datatables load all the 1000 queries and does client side pagination only.
This is my controller</p>

<pre><code> function view_ftth_report()
{

    if ($this-&gt;data['permission_ftth_report'] == '1') {
    $this-&gt;load-&gt;model('staff_activity_model');
    $this-&gt;data['records'] = $this-&gt;staff_activity_model-&gt;view_ftth_report();

    $this-&gt;data['main_template'] = 'staff_activity/staff_activity_main';
    $this-&gt;data['inner_template'] = 'staff_activity/ftth/staff_activity_ftth_report_view';
    $this-&gt;data['inner_nav'] = 'staff_activity/staff_activity_nav';
    $this-&gt;load-&gt;view('common/common', $this-&gt;data);
        }
    else{
        $this-&gt;data['main_template'] = 'staff_activity/staff_activity_main';
        $this-&gt;data['inner_template'] = 'staff_activity/staff_activity_denied';
        $this-&gt;data['inner_nav'] = 'staff_activity/staff_activity_nav_denied';
        $this-&gt;load-&gt;view('common/common', $this-&gt;data);
    }
}
</code></pre>

<p>This is my model.</p>

<pre><code>function view_ftth_report(){
    $sql = "SELECT * FROM ct_staff_activity_ftth ORDER BY date DESC limit 20  ";
    $data = array();
    $result = $this-&gt;db-&gt;query($sql);
    foreach($result-&gt;result_array() as $row)
    {
        $data[] = $row;
    }
    return $data;
}
</code></pre>

<p>And this is my view. I have used ajax to call the records .</p>

<pre><code>&lt;script type="text/javascript"&gt;

$(function() {
    $("#data_tbl").dataTable({
        "iDisplayLength": 50
    });

});
&lt;/script&gt;
&lt;div class="row"&gt;
&lt;div class="col-md-12"&gt;
    &lt;div class="box "&gt;
        &lt;div class="box-body"&gt;
            &lt;div class="row"&gt;
                &lt;div class="col-md-12"&gt;
                        &lt;a href="&lt;?php echo base_url();?&gt;staff_activity/date_report_index"&gt;&lt;button style="margin: 15px; padding: 10px; border-radius: 10px; border-collapse: collapse " class="btn btn-success btn-sm"&gt;Filter By Date&lt;/button&gt;&lt;/a&gt;

                    &lt;div class="col-md-12 table-responsive"&gt;
                        &lt;table class="table table-striped table-responsive" id="data_tbl"&gt;
                            &lt;h4&gt;Recent Entries&lt;/h4&gt;
                            &lt;thead&gt;
                            &lt;tr&gt;
                                &lt;th&gt;Sn.&lt;/th&gt;
                                &lt;th&gt;Client's Name&lt;/th&gt;
                                &lt;th&gt;Address&lt;/th&gt;
                                &lt;th&gt;Fiber Length&lt;/th&gt;
                                &lt;th&gt;Phone Number&lt;/th&gt;
                                &lt;th&gt;Package&lt;/th&gt;
                                &lt;th&gt;Result&lt;/th&gt;
                                &lt;th&gt;Date&lt;/th&gt;
                                &lt;th&gt;Team Name&lt;/th&gt;
                                &lt;th&gt;Remarks&lt;/th&gt;
                                &lt;th&gt;Edit&lt;/th&gt;
                                &lt;th&gt;Delete&lt;/th&gt;

                            &lt;/tr&gt;
                            &lt;/thead&gt;
                            &lt;tbody id="result"&gt;
 &lt;?php

                            $count = 0;

                            foreach($records as $rec){
                                $count = $count+1;

                                ?&gt;
                                &lt;tr&gt;
                                    &lt;td&gt;&lt;?php echo $count; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['client_name']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['address']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['fiber_length']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['phone_number']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['package']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['result']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['date']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['team_name']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;?php echo $rec['remarks']; ?&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;a href="&lt;?php echo base_url(); ?&gt;staff_activity/edit_ftth_report/&lt;?php echo $rec['id']?&gt;"&gt;Edit&lt;/a&gt;&lt;/td&gt;
                                    &lt;td&gt;&lt;a href="javascript:void(0)" onclick="chk('&lt;?php echo base_url(); ?&gt;staff_activity/delete_ftth_report/&lt;?php echo $rec['id']  ?&gt;')"&gt;Delete&lt;/a&gt;&lt;/td&gt;

                                &lt;/tr&gt;

                                &lt;?php

                            }

                            ?&gt;
                            &lt;/tbody&gt;

                        &lt;/table&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p></p>