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..

avatar hikamauthar
@hikamauthar

6 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

2 Jawaban:

<div>Coba bagian totalnya ditaruh di bagian tabel footer (tfoot), scriptnya kaya gini :<br><br></div><pre>&lt;?php if ($_GET[act]==''){ ?&gt; &lt;div class="col-xs-12"&gt;
&lt;div class="box"&gt; &lt;div class="box-header"&gt; &lt;h3 class="box-title"&gt;Catatan Cashflow&lt;/h3&gt; &lt;?php if($_SESSION[level]!='kepala'){ ?&gt; &lt;a class='pull-right btn btn-primary btn-sm' href='index.php?view=cashflow&amp;act=tambah'&gt;Tambahkan Data&lt;/a&gt; &lt;?php } ?&gt; &lt;/div&gt;&lt;!-- /.box-header --&gt; &lt;div class="box-body"&gt; &lt;table id="example1" class="table table-bordered table-striped"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th style='width:40px'&gt;No&lt;/th&gt; &lt;th&gt;Kode Anggaran&lt;/th&gt; &lt;th&gt;Keterangan&lt;/th&gt; &lt;th&gt;No Bukti&lt;/th&gt; &lt;th&gt;Tanggal&lt;/th&gt; &lt;th&gt;Penerimaan&lt;/th&gt; &lt;th&gt;Pengeluaran&lt;/th&gt; &lt;th&gt;Saldo&lt;/th&gt; &lt;?php if($_SESSION[level]!='kepala'){ ?&gt; &lt;th style='width:70px'&gt;Action&lt;/th&gt; &lt;?php } ?&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?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 "&lt;tr&gt;&lt;td&gt;$no&lt;/td&gt; &lt;td&gt;$r[kode_ma]&lt;/td&gt; &lt;td&gt;$r[keterangan]&lt;/td&gt; &lt;td&gt;$r[no_bkt]&lt;/td&gt; &lt;td&gt;$r[tgl]&lt;/td&gt; &lt;td&gt;Rp. ".number_format($r[debit])."&lt;/td&gt; &lt;td&gt;Rp. ".number_format($r[credit])."&lt;/td&gt; &lt;td&gt;Rp. ".number_format($saldo)."&lt;/td&gt;"; if($_SESSION[level]!='kepala'){ echo "&lt;td&gt;&lt;center&gt; &lt;a class='btn btn-success btn-xs' title='Edit Data' href='index.php?view=cashflow&amp;act=edit&amp;id=$r[kode_ma]'&gt;&lt;span class='glyphicon glyphicon-edit'&gt;&lt;/span&gt;&lt;/a&gt; &lt;a class='btn btn-danger btn-xs' title='Delete Data' href='index.php?view=cashflow&amp;hapus=$r[kode_ma]'&gt;&lt;span class='glyphicon glyphicon-remove'&gt;&lt;/span&gt;&lt;/a&gt; &lt;/center&gt;&lt;/td&gt;"; } echo "&lt;/tr&gt;"; $no++; }
if (isset($_GET[hapus])){ mysql_query("DELETE FROM rb_cashflow where kode_ma='$_GET[hapus]'"); echo "&lt;script&gt;document.location='index.php?view=cashflow';&lt;/script&gt;"; } ?&gt; &lt;/tbody&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;td colspan='5' style='text-align:right;'&gt;Total&lt;/td&gt; &lt;td&gt;Rp. &lt;?php echo number_format($debit); ?&gt;&lt;/td&gt; &lt;td&gt;Rp. &lt;?php echo number_format($credit); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;/table&gt; &lt;/div&gt;&lt;!-- /.box-body --&gt; &lt;/div&gt;&lt;!-- /.box --&gt; &lt;/div&gt;</pre><div><br>Semoga berhasil</div>

avatar ahanafi
@ahanafi

815 Kontribusi 554 Poin

Dipost 3 tahun yang lalu

<div>Terima kasih bny bang ane coba sudah berhasil ..</div>

avatar hikamauthar
@hikamauthar

6 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban