Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82150

Datatables loads all data

$
0
0
Hey guys,

I am new to datatables but I managed to find some code (over at: http://www.sharemycode.com/item/view/95/jquery-datatables-plugin-example-with-php-mysql) which I adapted to my my current table. It works fine, the only issue I have is the load time. It loads over 10,000 records and shows all of them before applying the formatting and paginating the records.

 
<?php
$con = mysql_connect("localhost", "root", "");

if (!$con) {
    die("Error: " . mysql_error());
}
mysql_select_db("newdl", $con);

$result = mysql_query("SELECT * FROM domains");
?>
<!DOCTYPE html>
<html>
    <head>
        <title>DataTables</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
        <script src="media/js/jquery.js" type="text/javascript"></script>
        <script src="media/js/jquery.dataTables.js" type="text/javascript"></script>
        
        <style type="text/css">
            @import "media/css/demo_table_jui.css";
            @import "media/themes/smoothness/jquery-ui-1.8.4.custom.css";
        </style>
        
        <style>
            *{
                font-family: arial;
            }
        </style>
        <script type="text/javascript" charset="utf-8">
            $(document).ready(function(){
                $('#datatables').dataTable({
                    "sPaginationType":"full_numbers",
                    "aaSorting":[[2, "desc"]],
                    "bJQueryUI":true
                });
            })
            
        </script>
        
    </head>
    <body>
        <div>
            
  <table id="datatables" class="display">
    <thead>
      <tr> 
        <th>Domain</th>
        <th>PageRank</th>
        <th>Text only coloum</th>
      </tr>
    </thead>
    <tbody>
      <?php
                    while ($row = mysql_fetch_array($result)) {
                        ?>
      <tr> 
        <td>
          <?=$row['domain']?>
        </td>
        <td>
          <?=$row['pr']?>
        </td>
        <td> Text</td>
      </tr>
      <?php
                    }
                    ?>
    </tbody>
  </table>
        </div>
    </body>
</html>

Is there anyway we can get over that issue?

Many thanks :)

Viewing all articles
Browse latest Browse all 82150

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>