DeferLoading through own php code or Javascript ( Server-side)

DeferLoading through own php code or Javascript ( Server-side)

ofb.rielcantalejoofb.rielcantalejo Posts: 11Questions: 5Answers: 1
edited September 2016 in Free community support

HI, will it be possible to implement Deferloading of my Datatables through my own php codes ?
I prefer to use my own codes as a Server-side and it works fine as i am used to it but i dont know how will i put the Deferloading feature here. Thanks for the help!

<?php

if ($result = $con->query("SELECT .id, circuiti, circuito, clienti, descrizione FROM Apples  
INNER JOIN Balls ON Apples.Cod = Balls.Cod  WHERE utenza =1 ORDER BY 
Apples.esercizio"))

{
if ($result->num_rows > 0)
{

// display records in a table
echo "  <table id='circuiti_table' class='table table-striped' name ='circuiti_tablename' >";

// set table headers
  echo " <thead><tr><th class = 'col1'></th><th></th> <th></th><th>Azienda</th>
                         <th>Circuito</th> <th>Descrizione</th><th>Note</th> </tr></thead><tbody > " ;

while ($row = $result->fetch_object()) 
{  echo "<tr>";
echo '<td><img src ="images/edit_icon.png" onclick="JavaScript:newPopup(\'circuiti_edit.php?id='.$row->id.'\')" /></td>';
echo '<td>Essercenti </td>'; 
echo '<td>Blacklist  </td>'; 
echo '<td>' .$row->es_insegna_esercizio. '</td>'; 
echo '<td>' .$row->Cod_circuito. '</td>'; 
echo '<td>' .$row->descrizione. '</td>'; 
echo '<td>' .$row->Note. '</td>'; 
echo "</tr>"; 
} 

echo "</tbody></table>"; 
}
// if there are no records in the database, display an alert message 
else  
{ 
echo "No results to display!"; 
} 
} 
// show an error if there is an issue with the database query 
else 
{ echo "Error: " . $con->error; } 
$con->close(); 
?>

Replies

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin

    What you have looks correct for the initial table. You'd typically want to use LIMIT to limit the first page to just 10 records, otherwise there would be no point in using server-side processing!

    Allan

  • ofb.rielcantalejoofb.rielcantalejo Posts: 11Questions: 5Answers: 1
    edited September 2016

    I will have more than 1000+ rows
    if i use my own code with datatables without enabling serverside will i have a problem loading it?

    Is the pagination i am using here is still client-side right? despite of my php and mysqli query?

    $(document).ready(function () { $('#circuiti_table').dataTable({ "oSearch": {"bSmart": false}, dom: '<"coll"B><"search"f><"table"t><"info" i><"list"l><"pag"p>',

    What i want to do is use this code while my pagination would be a Server-side because of loading data.

    thanks

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin

    if i use my own code with datatables without enabling serverside will i have a problem loading it?

    Only way to tell is to try it. It depends on your database and its connection speed. Typically client-side processing is okay up to around 50k rows.

    What i want to do is use this code while my pagination would be a Server-side because of loading data.

    If you want to use server-side processing, you have to implement server-side processing in your server-side script.

    Allan

  • ofb.rielcantalejoofb.rielcantalejo Posts: 11Questions: 5Answers: 1

    thanks allan

This discussion has been closed.