Advertisement
Yudhizth

Datatables Non Server Side Joomla

Jul 26th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.7/css/jquery.dataTables.css">
  4.         <script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  5.         <script type="text/javascript" language="javascript" src="http://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
  6.         <script type="text/javascript" language="javascript" >
  7.             $(document).ready( function () {
  8.                 $('#employee-grid').DataTable();
  9.             } );
  10.         </script>
  11.        
  12.     </head>
  13.     <body>
  14.         <h3 align="center">
  15.     Datatables Contoh
  16.   </h3>
  17.  
  18.   <?php $db = JFactory::getDbo();
  19.  
  20. // Create a new query object.
  21.  
  22. $query = $db->getQuery(true);
  23.  
  24. // Select all records from the user profile table where key begins with "custom.".
  25. // Order it by the ordering field.
  26. $query->select($db->quoteName(array('id', 'nama', 'nik')));
  27. $query->from($db->quoteName('#__form_contoh'));
  28. //$query->where($db->quoteName('profile_key') . ' LIKE '. $db->quote('\'custom.%\''));
  29. $query->order('id ASC');
  30.  
  31. // Reset the query using our newly populated query object.
  32. $db->setQuery($query);
  33.  
  34. // Load the results as a list of stdClass objects (see later for more options on retrieving data).
  35. $results = $db->loadObjectList(); ?>
  36.  
  37.             <table id="employee-grid"  cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
  38.                     <thead>
  39.                         <tr>
  40.                             <th>ID</th>
  41.                             <th>Nama</th>
  42.                             <th>NIK</th>
  43.                            
  44.                            
  45.                            
  46.                         </tr>
  47.                     </thead>
  48.                    
  49.                     <?php
  50.                         foreach($results as $result){
  51.                     echo "
  52. <td>".$result->id."</td>
  53. <td>".$result->nama."</td>
  54. <td>".$result->nik."</td>
  55.  
  56.  
  57. </tr>";
  58. }  
  59.                         ?>
  60.             </table>
  61.        
  62.     </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement