Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = 'localhost';
- $user = 'root';
- $pass = '4nt0n1u5';
- $db = 'e-report-2016';
- $koneksi = mysql_connect($host,$user,$pass) or die ('gagal koneksi');
- $pilih_db = mysql_select_db($db) or die ('salah pilih database"');
- function rupiah($nilai){
- $nilai_baru=number_format($nilai,0,',','.');
- return $nilai_baru;
- }
- ?>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
- </head>
- <body>
- <table id="example" class="display" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th>No. Trans</th>
- <th>Kode Rekening</th>
- <th>Jumlah</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <th>No. Trans</th>
- <th>Kode Rekening</th>
- <th>Jumlah</th>
- </tr>
- </tfoot>
- <tbody>
- <?php
- $sql="select no_trans,kode_rekening,jumlah from pengeluaran where jumlah > 1000000
- order by no_trans desc limit 1 ,25";
- $query=mysql_query($sql) or die (mysql_error());
- while($data=mysql_fetch_assoc($query)){
- ?>
- <tr>
- <td><?php echo $data['no_trans']; ?></td>
- <td><?php echo $data['kode_rekening']; ?></td>
- <td><?php echo rupiah($data['jumlah']); ?></td>
- </tr>
- <?php } ?>
- </tbody>
- </table>
- <script src="https://code.jquery.com/jquery-1.12.3.js"></script>
- <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
- <script>
- jQuery.extend( jQuery.fn.dataTableExt.oSort, {
- "my-currency-pre": function(a) {
- return parseFloat(a.replace(/ /gi, ''));
- },
- "my-currency-asc": function(a,b) {
- return ((a < b) ? -1 : ((a > b) ? 1 : 0));
- },
- "my-currency-desc": function(a,b) {
- return ((a < b) ? 1 : ((a > b) ? -1 : 0));
- }
- });
- var table = $('#example').dataTable({
- "aoColumnDefs": [
- {"sType": "my-currency", "aTargets": [2]}
- ],
- "order": [[ 2, 'asc' ],]
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement