Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
bagaimana cara mengatasi error pada tabel
mau tanya bagaimana cara menghilangkan error pada tabel ya? berikut screenshot dan codingannya :
error.png
<?php if ($_GET[act]==''){ ?>
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title">Catatan Cashflow</h3>
<?php if($_SESSION[level]!='kepala'){ ?>
<a class='pull-right btn btn-primary btn-sm' href='index.php?view=cashflow&act=tambah'>Tambahkan Data</a>
<?php } ?>
</div><!-- /.box-header -->
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th style='width:40px'>No</th>
<th>Kode Anggaran</th>
<th>Keterangan</th>
<th>No Bukti</th>
<th>Tanggal</th>
<th>Penerimaan</th>
<th>Pengeluaran</th>
<th>Saldo</th>
<?php if($_SESSION[level]!='kepala'){ ?>
<th style='width:70px'>Action</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
$tampil = mysql_query("SELECT * FROM rb_cashflow ORDER BY kode_ma DESC");
$no = 1;
$saldo=0;
$total=0;
while($r=mysql_fetch_array($tampil)){
$saldo = $saldo + $r[debit];
$saldo = $saldo - $r[credit];
$debit = $debit + $r[debit];
$credit = $credit + $r[credit];
echo "<tr><td>$no</td>
<td>$r[kode_ma]</td>
<td>$r[keterangan]</td>
<td>$r[no_bkt]</td>
<td>$r[tgl]</td>
<td>Rp. ".number_format($r[debit])."</td>
<td>Rp. ".number_format($r[credit])."</td>
<td>Rp. ".number_format($saldo)."</td>";
if($_SESSION[level]!='kepala'){
echo "<td><center>
<a class='btn btn-success btn-xs' title='Edit Data' href='index.php?view=cashflow&act=edit&id=$r[kode_ma]'><span class='glyphicon glyphicon-edit'></span></a>
<a class='btn btn-danger btn-xs' title='Delete Data' href='index.php?view=cashflow&hapus=$r[kode_ma]'><span class='glyphicon glyphicon-remove'></span></a>
</center></td>";
}
echo "</tr>";
$no++;
}
echo "<tr>
<td colspan='5' style='text-align:right;'>Total</td>
<td>Rp. ".number_format($debit)."</td>
<td>Rp. ".number_format($credit)."</td>
<td colspan='2'></td>";
echo "</tr>";
if (isset($_GET[hapus])){
mysql_query("DELETE FROM rb_cashflow where kode_ma='$_GET[hapus]'");
echo "<script>document.location='index.php?view=cashflow';</script>";
}
?>
</tbody>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div>
mungkin ada yang bisa bantu..
2 Jawaban:
<div>Coba bagian totalnya ditaruh di bagian tabel footer (tfoot), scriptnya kaya gini :<br><br></div><pre><?php if ($_GET[act]==''){ ?>
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title">Catatan Cashflow</h3>
<?php if($_SESSION[level]!='kepala'){ ?>
<a class='pull-right btn btn-primary btn-sm' href='index.php?view=cashflow&act=tambah'>Tambahkan Data</a>
<?php } ?>
</div><!-- /.box-header -->
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th style='width:40px'>No</th>
<th>Kode Anggaran</th>
<th>Keterangan</th>
<th>No Bukti</th>
<th>Tanggal</th>
<th>Penerimaan</th>
<th>Pengeluaran</th>
<th>Saldo</th>
<?php if($_SESSION[level]!='kepala'){ ?>
<th style='width:70px'>Action</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
$tampil = mysql_query("SELECT * FROM rb_cashflow ORDER BY kode_ma DESC");
$no = 1;
$saldo=0;
$total=0;
while($r=mysql_fetch_array($tampil)){
$saldo = $saldo + $r[debit];
$saldo = $saldo - $r[credit];
$debit = $debit + $r[debit];
$credit = $credit + $r[credit];
echo "<tr><td>$no</td>
<td>$r[kode_ma]</td>
<td>$r[keterangan]</td>
<td>$r[no_bkt]</td>
<td>$r[tgl]</td>
<td>Rp. ".number_format($r[debit])."</td>
<td>Rp. ".number_format($r[credit])."</td>
<td>Rp. ".number_format($saldo)."</td>";
if($_SESSION[level]!='kepala'){
echo "<td><center>
<a class='btn btn-success btn-xs' title='Edit Data' href='index.php?view=cashflow&act=edit&id=$r[kode_ma]'><span class='glyphicon glyphicon-edit'></span></a>
<a class='btn btn-danger btn-xs' title='Delete Data' href='index.php?view=cashflow&hapus=$r[kode_ma]'><span class='glyphicon glyphicon-remove'></span></a>
</center></td>";
}
echo "</tr>";
$no++;
}
if (isset($_GET[hapus])){
mysql_query("DELETE FROM rb_cashflow where kode_ma='$_GET[hapus]'");
echo "<script>document.location='index.php?view=cashflow';</script>";
}
?>
</tbody>
<tfoot>
<tr>
<td colspan='5' style='text-align:right;'>Total</td>
<td>Rp. <?php echo number_format($debit); ?></td>
<td>Rp. <?php echo number_format($credit); ?></td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div></pre><div><br>Semoga berhasil</div>
<div>Terima kasih bny bang ane coba sudah berhasil ..</div>