Assalamualaikum Warahmatullahi Wabarakatuh...
Saya mempunyai beberapa inputan yang memiliki total nilai. Saya ingin mengurutkan total nilai tersebut dari yang tertinggi ke yang TerRendah. Adapun Contoh gambar saya upload di lampiran.
Adapun script yang sejauh ini saya tulis adalah sebagai berikut :
#View#
<table class="table table-striped">
<thead>
<tr>
<th data-field="" data-checkbox="true" >No</th>
<th data-field="" data-sortable="true">NIK Penduduk</th>
<th data-field="" data-sortable="true">Nama Mahasiswa</th>
<th data-field="" data-sortable="true">Tempat Lahir</th>
<th data-field="" data-sortable="true">Universitas</th>
<th data-field="" data-sortable="true">Kecamatan</th>
<th data-field="" data-sortable="true">Nagari</th>
<th data-field="" data-sortable="true">Parameter</th>
<th data-field="" data-sortable="true">Total Nilai</th>
</tr>
</thead>
<tbody>
<?php $no=0;
foreach ($tb_laporan -> result() as $rows) {
$id=$rows->id_api_penduduk;
$cek = $this->aktifrecord->penduduk_all($id);
foreach ($cek -> result() as $rowx) {
$no++;
//JML ANGGOTA KK
if($rows->jml_anggota_kk <5){
$b_anggota='2';
}elseif($rows->jml_anggota_kk ==5 || $rows->jml_anggota_kk ==6){
$b_anggota='4';
}else{
$b_anggota='6';
}
//DTKS
if($rows->dtks =='Ya'){
$b_dtks='25';
}else{
$b_dtks='0';
}
//IPK
if($rows->ipk >='3' && $rows->ipk <='3.05'){
$b_ipk='1';
}elseif($rows->ipk >='3.06' && $rows->ipk <='3.1'){
$b_ipk='2';
}elseif($rows->ipk >='3.11' && $rows->ipk <='3.15'){
$b_ipk='3';
}elseif($rows->ipk >='3.16' && $rows->ipk <='3.2'){
$b_ipk='4';
}elseif($rows->ipk >='3.21' && $rows->ipk <='3.25'){
$b_ipk='5';
}elseif($rows->ipk >='3.26' && $rows->ipk <='3.3'){
$b_ipk='6';
}elseif($rows->ipk >='3.31' && $rows->ipk <='3.35'){
$b_ipk='7';
}elseif($rows->ipk >='3.36' && $rows->ipk <='3.4'){
$b_ipk='8';
}elseif($rows->ipk >='3.41' && $rows->ipk <='3.45'){
$b_ipk='9';
}elseif($rows->ipk >='3.46' && $rows->ipk <='3.5'){
$b_ipk='10';
}elseif($rows->ipk >='3.51' && $rows->ipk <='3.55'){
$b_ipk='11';
}elseif($rows->ipk >='3.56' && $rows->ipk <='3.6'){
$b_ipk='12';
}elseif($rows->ipk >='3.61' && $rows->ipk <='3.65'){
$b_ipk='13';
}elseif($rows->ipk >='3.66' && $rows->ipk <='3.7'){
$b_ipk='14';
}elseif($rows->ipk >='3.71' && $rows->ipk <='3.75'){
$b_ipk='15';
}elseif($rows->ipk >='3.76' && $rows->ipk <='3.8'){
$b_ipk='16';
}elseif($rows->ipk >='3.81' && $rows->ipk <='3.85'){
$b_ipk='17';
}elseif($rows->ipk >='3.86' && $rows->ipk <='3.9'){
$b_ipk='18';
}elseif($rows->ipk >='3.91' && $rows->ipk <='3.95'){
$b_ipk='19';
}else{
$b_ipk='20';
}
//Bnyk Prestasi
if($rows->byk_prestasi >2){
$b_prestasi='4';
}elseif($rows->byk_prestasi ==2){
$b_prestasi='2';
}elseif($rows->byk_prestasi ==1){
$b_prestasi='1';
}else{
$b_prestasi='0';
}
//Akreditasi Perguruan tinggi
if($rows->id_akt =='1'){
$b_mutu='25';
}elseif($rows->id_akt =='2'){
$b_mutu='15';
}else{
$b_mutu='0';
}
//Nilai Hafiz Qur'an
if($rows->id_hafiz ==6){
$b_hafiz='6';
}elseif($rows->id_hafiz ==5){
$b_hafiz='4';
}elseif($rows->id_hafiz ==4){
$b_hafiz='3';
}elseif($rows->id_hafiz ==3){
$b_hafiz='2';
}elseif($rows->id_hafiz ==2){
$b_hafiz='1';
}elseif($rows->id_hafiz ==1){
$b_hafiz='0';
}else{
$b_prestasi='0';
}
//Kendaraan
if($rows->id_kendaraan =='2'){
$b_kendaraan='5';
}else{
$b_kendaraan='0';
}
//Rumah
if($rows->id_rumah =='2'){
$b_rumah='5';
}else{
$b_rumah='0';
}
// Perguruan Tinggi
if($rows->id_pt ==99){
$b_pt='1';
$n_pt=$rows->pt_lainnya;
}elseif($rows->id_pt ==1){
$b_pt='4';
}elseif($rows->id_pt ==2){
$b_pt='4';
}elseif($rows->id_pt ==3){
$b_pt='4';
}elseif($rows->id_pt ==4){
$b_pt='4';
}elseif($rows->id_pt ==5){
$b_pt='4';
}elseif($rows->id_pt ==6){
$b_pt='3';
}elseif($rows->id_pt ==7){
$b_pt='3';
}else{
$b_prestasi='0';
}
?>
<tr>
<td class="center"><?php echo $no?></td>
<td class="center"><?php echo $rowx->nik ?></td>
<td class="center"><?php echo $rowx->nama ?></td>
<td class="center"><?php echo $rowx->tmplahir.' / '.$rowx->tgllahir ?></td>
<td class="center"><?php if ($rows->id_pt=='99'){$nmpt=$rows->pt_lainnya;}else{$nmpt=$rows->pt;} echo $nmpt?></td>
<td class="center"><?php echo $rowx->nm_kec ?></td>
<td class="center"><?php echo $rowx->nm_nagari ?></td>
<td class="center">
<li data-sortable ="true">Nilai Bobot DTKS : <b><?php echo $b_dtks?></b></li>
<li data-sortable ="true">Nilai Bobot Rumah : <b><?php echo $b_rumah?></b></li>
<li data-sortable ="true">Nilai Bobot Kendaraan : <b><?php echo $b_kendaraan?></b></li>
<li data-sortable ="true">Nilai Bobot Anggota Keluarga : <b><?php echo $b_anggota?></b></li>
<li data-sortable ="true">Nilai Bobot Prestasi : <b><?php echo $b_prestasi?></b></li>
<li data-sortable ="true">Nilai Bobot IPK : <b><?php echo $b_ipk?></b></li>
<li data-sortable ="true">Nilai Bobot Perguruan Tinggi : <b><?php echo $b_pt?></b></li>
<li data-sortable ="true">Nilai Bobot Akreditasi : <b><?php echo $b_mutu?></b></li>
<li data-sortable ="true">Nilai Bobot Hafiz : <b><?php echo $b_hafiz?></b></li>
</td>
<td class="center" align="center" bgcolor="#FFFF00"><b><?php $total = $b_rumah + $b_kendaraan +
$b_anggota + $b_dtks + $b_prestasi + $b_ipk + $b_mutu + $b_hafiz + $b_pt;
$total_arr[$b_pt] = $total;
echo $total;?></b>
</td>
</tr>
<?php
} }
?>
</tbody>
</table><hr>
#Controller#
<?php
class Pendaftaran extends CI_Controller
{
function __construct()
{
parent::__construct();
if($this->session->userdata('masuk') !=TRUE)
{
$url=base_url('administrator');
redirect($url);
};
$this->load->model('Aktifrecord','aktifrecord');
$this->load->model('Aktifrecord1','aktifrecord1');
}
public function nik($id)
{
$data['cek'] = $this->aktifrecord->mhs($id);
$data['lap'] = $this->aktifrecord1->lap($id);
$this->load->view('admin/v_pendaftaran',$data);
}
function index()
{
$x['tb_laporan']=$this->aktifrecord1->get_all_laporan();
$this->load->view('admin/v_admin',$x);
}
}
#Model#
function get_all_laporan(){
$hsl=$this->db->query("SELECT * FROM tb_laporan l LEFT JOIN tb_pt pt ON l.id_pt=pt.id_pt ORDER BY l.id_laporan DESC");
return $hsl;
}
Terimakasih....