Postingan lainnya
Filter data berdasarkan range tanggal menggunakan datepicker
<div class="ibox-body">
<script>
$(function() {
$(".datepicker").datepicker({
format: 'd-m-Y',
autoclose: true,
todayHighlight: false,
});
$("#start").on('changeDate', function(selected) {
var startDate = new Date(selected.date.valueOf());
$("#end").datepicker('setStartDate', startDate);
if($("#start").val() > $("#end").val()){
$("#end").val($("#start").val());
}
});
});
</script>
<form class="form-inline">
<?php
if(isset($_GET['cari'])){
error_reporting(E_ALL * (E_NOTICE | E_WARNING));
$start=date('d-m-Y', strtotime($_POST["start"]));
$end=date('d-m-Y', strtotime($_POST["end"]));
$sql="SELECT * FROM tbl_arsip where tanggal between '$start' and '$end' order by tanggal desc";
}else{
$sql="SELECT * FROM tbl_arsip order by tanggal desc";
}
?>
<label class="col-sm-1 col-form-label">Tanggal</label>
<div class="input-daterange input-group" id="datepicker">
<input class="input-sm form-control" id="start" type="date" name="start" required>
<span class="input-group-addon p-l-10 p-r-10">s/d</span>
<input class="input-sm form-control" id="end" type="date" name="end" required>
</div>
<button class="btn btn-info" type="submit" name="cari"><i class="fa fa-search"></i> Search</button>
</form>
</div>
<div class="page-content fade-in-up">
<div class="ibox">
<div class="ibox-body">
<table class="table table-striped table-bordered table-hover" id="example-table" cellspacing="0" width="100%">
<thead>
<tr>
<th width="8%" class="text-center">Nopen</th>
<th width="11%" class="text-center">Tanggal</th>
<th width="26%" class="text-center">Nama PT</th>
<th width="10%" class="text-center">Jenis Dokumen</th>
<th width="3%" class="text-center">Rak</th>
<th width="4%" class="text-center">Box</th>
<th width="7%" class="text-center">Keterangan</th>
</tr>
</thead>
<tbody>
<?php
error_reporting(E_ALL * (E_NOTICE | E_WARNING));
$no=1;
$start=date('d-m-Y', strtotime($_POST["start"]));
$end=date('d-m-Y', strtotime($_POST["end"]));
$ambil=$koneksi->query("SELECT * FROM tbl_arsip order by tanggal desc");
while($pecah=$ambil->fetch_assoc()){
?>
<tr>
<td class="text-center"><?php echo $pecah['nopen']; ?></td>
<td class="text-center"><?php echo date('d-M-Y', strtotime($pecah['tanggal'])); ?></td>
<td class="text-uppercase"><?php echo $pecah['nama_pt']; ?></td>
<td class="text-center"><?php echo $pecah['jenisdoc']; ?></td>
<td class="text-center"><?php echo $pecah['rak']; ?></td>
<td class="text-center"><?php echo $pecah['box']; ?></td>
<td class="text-center"><?php echo $pecah['ket']; ?></td>
</tr>
<?php
$no++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
0
Tanggapan
Dia tidak mau menampilkan data berdasarkan range tangal yg sdh diinput. Mohon bantuannya kakak abg
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban