Menampilkan data php oop error

Guys mohon maaf yak, ini saya nampilin data dengan php oop saya lampirkan full script disini karena anehnya, ketika saya taruh looping di table, trus dri table kebawah itu scriptnya gak muncul sampai footer yang ke include aja ngilang jadi mohon saran y
<?php include 'template_part/header/header-tab.php';?>
<?php include 'db.data.php';?>
<?php include 'inc/functions.php';?>

<div class="col-md-12 col-xs-12" style="margin-top:10px">
  <div class="row" style="margin-left:10px;margin-bottom:10px">
    <div class="col-md-4">
      <h5 style="border-bottom:1px solid grey;">Input Barang :</h5>
      <form action="inptbarang.php" method="post">
        <div class="form-group">
          <label>Nama barang</label>
          <input type="text" name="nm" class="form-control form-control-sm" placeholder="Example input">
        </div>
        <div class="form-group">
          <label>Keterangan</label>
          <input type="text" name="kt" class="form-control form-control-sm" placeholder="Another input">
        </div>
        <div class="form-group">
          <label>Harga Barang</label>
          <input type="text" name="hrg" class="form-control form-control-sm" placeholder="Format : 1000000 / 1500000">
        </div>
        <div class="form-group">
          <label>Jumlah barang</label>
          <input type="number" name="jml" class="form-control form-control-sm" placeholder="Example input">
        </div>	public function fetch_multiple($sql){
		$data="";
		$result = mysqli_query($this->mysqli,$sql);
		while($row = mysqli_fetch_array($result)){
			$data[] = $row;
		}
		return $data;
	}
        <div class="form-group">
          <label>Tahun Pembuatan</label>
          <input type="text" name="thn" class="form-control form-control-sm" placeholder="Another input">
        </div>
        <div class="form-group">
          <label>Kondisi Barang</label>
          <select class="custom-select" name="knds">
            <option selected>Plih Kondisi barang</option>
            <option value="B">Baik</option>
            <option value="TB">Tidak Baik</option>
          </select>
        </div>
        <input type="hidden" name="act" value="add-data">
        <button type="submit" class="btn btn-primary" id="tombol-simpan" style="margin-top:10px;float:right">Input Data barang</button>
      </form>
    </div>
    <div class="col-md-8">
      </form>
      <h5 style="border-bottom:1px solid grey;">Data Barang:</h5>
      <div class="rightss">
        <form class="form-inline my-2 my-lg-0" action="cari.php" method="post">
          <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
          <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
      </div>
      <div class="clearfix"></div>
      <div class="pesan" style="display:none;">
        <div class="alert alert-success alert-dismissible fade show" role="alert">
          <p id="pesan"></p>
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
      </div>
      <table class="table table-bordered table-striped table-condensed datatables">
        <thead>
          <th>Kode Barang</th>
          <th>Nama Barang</th>
          <th>Jumlah</th>
          <th>Kondisi</th>
          <th>Status</th>
        </thead>
        <tbody>
          <?php
          $total = $db->num_rows("select kd_brng from brng_pbo");
          $data_ctn = $db->fetch_multiple('select kd_brng,nm_brng,qty,knds from brng_pbo');

          if(is_array($data_ctn))
          {
            foreach ($data_ctn as $ctn)
            {
              $kd = $ctn['kd_brng'];
              $nm = $ctn['nm_brng'];
              $qty = $ctn['qty'];
              $knds = $ctn['knds'];
              $sts = $ctn['status'];
              ?>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          	<?php
          }}
          ?>
        </tbody>
      </table>
    </div>
  </div>
</div>
<?php include'template_part/footer/footer.php';?>

ini Hasil Code diatas 2rcsizt.jpg ini tanpa code php 2nleovs.jpg jadinya saya bingung errornya itu dmn saya include untuk function fetch_multiplenya
	public function fetch_multiple($sql){
		$data="";
		$result = mysqli_query($this->mysqli,$sql);
		while($row = mysqli_fetch_array($result)){
			$data[] = $row;
		}
		return $data;
	}
avatar maszgalang

@maszgalang

297 Kontribusi 80 Poin

  • cek buka tutup phpnya ada belum ditulis - @Shefin17
  • Udh semua saya chek udh ketutup semua - @maszgalang
  • coba di print_r $row,dan tampilkan erro message - @Shefin17


Jawaban Terpilih

Case close harusnya variable datanya saat dibuat harus berbentuk array()
$data=[];

//jadi bisa digunakan sebagai array

$data[] = $row;
avatar maszgalang

@maszgalang

297 Kontribusi 80 Poin

Jawaban

<?php include 'template_part/header/header-tab.php';?>
<?php include 'db.data.php';?>
<?php include 'inc/functions.php';?>

<div class="col-md-12 col-xs-12" style="margin-top:10px">
  <div class="row" style="margin-left:10px;margin-bottom:10px">
    <div class="col-md-4">
      <h5 style="border-bottom:1px solid grey;">Input Barang :</h5>
      <form action="inptbarang.php" method="post">
        <div class="form-group">
          <label>Nama barang</label>
          <input type="text" name="nm" class="form-control form-control-sm" placeholder="Example input">
        </div>
        <div class="form-group">
          <label>Keterangan</label>
          <input type="text" name="kt" class="form-control form-control-sm" placeholder="Another input">
        </div>
        <div class="form-group">
          <label>Harga Barang</label>
          <input type="text" name="hrg" class="form-control form-control-sm" placeholder="Format : 1000000 / 1500000">
        </div>
        <div class="form-group">
          <label>Jumlah barang</label>
          <input type="number" name="jml" class="form-control form-control-sm" placeholder="Example input">
        </div>	
         <?php public function fetch_multiple($sql){
		$data="";
		$result = mysqli_query($this->mysqli,$sql);
		while($row = mysqli_fetch_array($result)){
			$data[] = $row;
		}
		return $data;
	} ?>
        <div class="form-group">
          <label>Tahun Pembuatan</label>
          <input type="text" name="thn" class="form-control form-control-sm" placeholder="Another input">
        </div>
        <div class="form-group">
          <label>Kondisi Barang</label>
          <select class="custom-select" name="knds">
            <option selected>Plih Kondisi barang</option>
            <option value="B">Baik</option>
            <option value="TB">Tidak Baik</option>
          </select>
        </div>
        <input type="hidden" name="act" value="add-data">
        <button type="submit" class="btn btn-primary" id="tombol-simpan" style="margin-top:10px;float:right">Input Data barang</button>
      </form>
    </div>
    <div class="col-md-8">
      </form>
      <h5 style="border-bottom:1px solid grey;">Data Barang:</h5>
      <div class="rightss">
        <form class="form-inline my-2 my-lg-0" action="cari.php" method="post">
          <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
          <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
      </div>
      <div class="clearfix"></div>
      <div class="pesan" style="display:none;">
        <div class="alert alert-success alert-dismissible fade show" role="alert">
          <p id="pesan"></p>
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
      </div>
      <table class="table table-bordered table-striped table-condensed datatables">
        <thead>
          <th>Kode Barang</th>
          <th>Nama Barang</th>
          <th>Jumlah</th>
          <th>Kondisi</th>
          <th>Status</th>
        </thead>
        <tbody>
          <?php
          $total = $db->num_rows("select kd_brng from brng_pbo");
          $data_ctn = $db->fetch_multiple('select kd_brng,nm_brng,qty,knds from brng_pbo');

          if(is_array($data_ctn))
          {
            foreach ($data_ctn as $ctn)
            {
              $kd = $ctn['kd_brng'];
              $nm = $ctn['nm_brng'];
              $qty = $ctn['qty'];
              $knds = $ctn['knds'];
              $sts = $ctn['status'];
              ?>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          	<?php
          }}
          ?>
        </tbody>
      </table>
    </div>
  </div>
</div>
<?php include'template_part/footer/footer.php';?>
cba itu, kmu ada error di kodenya
avatar ashleenanh46

@ashleenanh46

21 Kontribusi 5 Poin


Case close harusnya variable datanya saat dibuat harus berbentuk array()
$data=[];

//jadi bisa digunakan sebagai array

$data[] = $row;
avatar maszgalang

@maszgalang

297 Kontribusi 80 Poin


Login untuk gabung berdiskusi