BAB IV DatatabledanModel (Web) Fix
BAB IV DatatabledanModel (Web) Fix
<?php
class Modeldb extends CI_model{
public function get_all($table)
{
return $this->db->get($table);
}
$data['user']=$this->Modeldb->get_all('user
')->result_array();
6. Buat Table dengan Data Table
<div id="layoutSidenav_content">
<main>
<div class="container-fluid px-4">
</div>
<div style="padding: 10px;">
<?php echo $this->session->flashdata('pesan'); ?>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary"><?php echo $title ?></h6>
</div>
<div class="card-body">
<center>
<h3> Data User</h3>
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<td width="150">No.</td>
<td width="250">Nama</td>
<td width="200">Username</td>
<td width="200">Password</td>
<td>Level</td>
<td width="200">Aksi</td>
</tr>
</thead>
<tbody>
<?php $no=1; foreach ($user as $j):?>
<tr>
<td>
<?php echo $no++?>
</td>
<td><?php echo $j['name']?></td>
<td><?php echo $j['username']?></td>
<td><?php echo $j['password']?></td>
<td><?php echo $j['level']?></td>
<td width="150">
<a class="btn btn-sm btn-primary" href="<?php echo
base_url('admin/Tampiluser/updateData/'.$j['iduser']) ?>"><i class="fas fa-edit"></i></a>
<a class="btn btn-sm btn-primary" href="<?php echo
base_url('admin/Tampiluser/deleteData/'.$j['iduser']) ?>"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</center>
</div>
</div>
<script>
$(document).ready( function () {
$('#myTable').DataTable();
} );
</script>
<script>
$(document).ready(function(){
$('input[type="file"]').change(function(e){
var fileName = e.target.files[0].name;
alert('The file "' + fileName + '" has been selected.');
});
});
</script>
<script src="https://cdn.datatables.net/2.0.5/js/dataTables.js"></script>
<script>
$(document).ready(function(){
$('input[type="file"]').change(function(e){
var fileName = e.target.files[0].name;
alert('The file "' + fileName + '" has been selected.');
});
});
</script>
8. Jalankan localhost/penjualan/input data user