Commit e3f5d90a by Roy Junedi Simamora

fungsi menampilkan data menu makanan

parent b7bf92e5
<?php include 'koneksi.php'; ?>
<?php include 'common/header.php'; ?>
<h3><span class="glyphicon glyphicon-shopping-cart"></span> Daftar Menu </h3>
<button style="margin-bottom:20px" data-toggle="modal" data-target="#myModal" class="btn btn-warning col-md-2"><span class="glyphicon glyphicon-plus"></span>Tambah Menu</button>
<br/>
<br/>
<?php
$per_hal = 10;
$jumlah_record = mysql_query("SELECT COUNT(*) from menu");
$jum = mysql_result($jumlah_record, 0);
$halaman = ceil($jum / $per_hal);
$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>
</div>
<form action="cari.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 menu 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-3">Gambar</th>
<th class="col-md-2">Nama Barang</th>
<th class="col-md-2">Harga</th>
<th class="col-md-2"> Kategori </th>
<!-- <th class="col-md-1">Sisa</th> -->
<th class="col-md-3">Opsi</th>
</tr>
<?php
if (isset($_GET['cari'])) {
$cari = mysql_real_escape_string($_GET['cari']);
$menu = mysql_query("select * from menu where nama like '$cari' or kategori_id like '$cari'");
} else {
$menu = mysql_query("select * from menu limit $start, $per_hal");
}
$no = 1;
while ($b = mysql_fetch_array($menu)) {
?>
<tr>
<td><?php echo $no++ ?></td>
<td>
<img class="img-responsive" src="picture/<?php echo $b['gambar']; ?>" width="150" height="100">
</td>
<td><?php echo $b['nama'] ?></td>
<td>Rp.<?php echo number_format($b['harga']) ?>,-</td>
<td><?php
if ($b['kategori_id'] == 1) {
echo 'Makanan';
} else if ($b['kategori_id'] == 2) {
echo 'Minuman';
}
?>
</td>
<td>
<a href="detail.php?id=<?php echo $b['id_menu']; ?>" class="btn btn-success"><span class="glyphicon glyphicon-eye-open"> </span></a>
<a href="edit.php?id=<?php echo $b['id_menu']; ?>" class="btn btn-info"><span class="glyphicon glyphicon-edit"></span></a>
<a onclick="if (confirm('Apakah anda yakin ingin menghapus data ini ??')) {
location.href = 'delete.php?id=<?php echo $b['id_menu']; ?>'
}" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span></a>
</td>
</tr>
<?php
}
?>
</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">&times;</button>
<h4 class="modal-title">Tambah Menu</h4>
</div>
<div class="modal-body">
<form action="tambah_proses.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label> Gambar </label>
<input type="file" name="gambar" class="form-control">
</div>
<div class="form-group">
<label>Nama</label>
<input name="nama" type="text" class="form-control" placeholder="Nama Menu .."/>
</div>
<div class="form-group">
<label>Harga</label>
<input name="harga" type="text" class="form-control" placeholder="Harga Jual per porsi"/>
</div>
<div class="form-groups">
<label>Kategori</label>
<input name="kategori" type="radio" value="1"> Makanan
<input name="kategori" type="radio" value="2"> Minuman
</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 'common/footer.php';
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment