I need your help please. I got an error about "Unsupported operand types" but i didn't know about it. i've been trying search on google but i'm still can't fix it.
this my error title :
Fatal error: Uncaught Error: Unsupported operand types in /Applications/XAMPP/xamppfiles/htdocs/aplikasi_penjualan/admin/barang.php:28 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/aplikasi_penjualan/admin/barang.php on line 28
and this my code :
<?php include 'header.php'; ?>
<h3><span class="glyphicon glyphicon-briefcase"></span> Data Barang</h3>
<button style="margin-bottom:20px" data-toggle="modal" data-target="#myModal" class="btn btn-info col-md-2"><span class="glyphicon glyphicon-plus"></span>Tambah Barang</button>
<br/>
<br/>
<?php
$periksa=mysqli_query($conn, "select * from barang where jumlah <=3");
while($q=mysqli_fetch_array($periksa)){
if($q['jumlah']<=3){
?>
<script>
$(document).ready(function(){
$('#pesan_sedia').css("color","red");
$('#pesan_sedia').append("<span class='glyphicon glyphicon-asterisk'></span>");
});
</script>
<?php
echo "<div style='padding:5px' class='alert alert-warning'><span class='glyphicon glyphicon-info-sign'></span> Stok <a style='color:red'>". $q['nama']."</a> yang tersisa sudah kurang dari 3 . silahkan pesan lagi !!</div>";
}
}
?>
<?php
// $per_hal=10;
$jumlah_record=mysqli_query($conn, "SELECT COUNT(*) from barang");
$jum=mysqli_fetch_array($jumlah_record);
$halaman= ceil($jum / $per_hal); //-----> THE ERROR IN HERE
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_hal;
?>
<div class="col-md-12">
<table class="col-md-2">
<tr>
<td>Jumlah Record</td>
<td><?php echo $jum; ?></td>
</tr>
<tr>
<td>Jumlah Halaman</td>
<td><?php echo $halaman; ?></td>
</tr>
</table>
<a style="margin-bottom:10px" href="lap_barang.php" target="_blank" class="btn btn-default pull-right"><span class='glyphicon glyphicon-print'></span> Cetak</a>
</div>
<form action="cari_act.php" method="get">
<div class="input-group col-md-5 col-md-offset-7">
<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-search"></span></span>
<input type="text" class="form-control" placeholder="Cari barang di sini .." aria-describedby="basic-addon1" name="cari">
</div>
</form>
<br/>
<table class="table table-hover">
<tr>
<th class="col-md-1">No</th>
<th class="col-md-4">Nama Barang</th>
<th class="col-md-3">Harga Jual</th>
<th class="col-md-1">Jumlah</th>
<!-- <th class="col-md-1">Sisa</th> -->
<th class="col-md-3">Opsi</th>
</tr>
<?php
if(isset($_GET['cari'])){
$cari=mysqli_real_escape_string($_GET['cari']);
$brg=mysqli_query($conn, "select * from barang where nama like '$cari' or jenis like '$cari'");
}else{
$brg=mysqli_query($conn, "select * from barang limit $start, $per_hal");
}
$no=1;
while($b=mysqli_fetch_array($brg)){
?>
<tr>
<td><?php echo $no++ ?></td>
<td><?php echo $b['nama'] ?></td>
<td>Rp.<?php echo number_format($b['harga']) ?>,-</td>
<td><?php echo $b['jumlah'] ?></td>
<td>
<a href="det_barang.php?id=<?php echo $b['id']; ?>" class="btn btn-info">Detail</a>
<a href="edit.php?id=<?php echo $b['id']; ?>" class="btn btn-warning">Edit</a>
<a onclick="if(confirm('Apakah anda yakin ingin menghapus data ini ??')){ location.href='hapus.php?id=<?php echo $b['id']; ?>' }" class="btn btn-danger">Hapus</a>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4">Total Modal</td>
<td>
<?php
$x=mysqli_query($conn, "select sum(modal) as total from barang");
$xx=mysqli_fetch_array($x);
echo "<b> Rp.". number_format($xx['total']).",-</b>";
?>
</td>
</tr>
</table>
<ul class="pagination">
<?php
for($x=1;$x<=$halaman;$x++){
?>
<li><a href="?page=<?php echo $x ?>"><?php echo $x ?></a></li>
<?php
}
?>
</ul>
<!-- modal input -->
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Tambah Barang Baru</h4>
</div>
<div class="modal-body">
<form action="tmb_brg_act.php" method="post">
<div class="form-group">
<label>Nama Barang</label>
<input name="nama" type="text" class="form-control" placeholder="Nama Barang ..">
</div>
<div class="form-group">
<label>Jenis</label>
<input name="jenis" type="text" class="form-control" placeholder="Jenis Barang ..">
</div>
<div class="form-group">
<label>Suplier</label>
<input name="suplier" type="text" class="form-control" placeholder="Suplier ..">
</div>
<div class="form-group">
<label>Harga Modal</label>
<input name="modal" type="text" class="form-control" placeholder="Modal per unit">
</div>
<div class="form-group">
<label>Harga Jual</label>
<input name="harga" type="text" class="form-control" placeholder="Harga Jual per unit">
</div>
<div class="form-group">
<label>Jumlah</label>
<input name="jumlah" type="text" class="form-control" placeholder="Jumlah">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
<input type="submit" class="btn btn-primary" value="Simpan">
</div>
</form>
</div>
</div>
</div>
<?php
include 'footer.php';
?>
I Hope you can help me.. Thanks a lot.
Aucun commentaire:
Enregistrer un commentaire