Textbox terisi tanggal otomatis

Pain Akuto · May 3, 2013
Selamat sore,

Mohon bantuannya, saya sedang mencoba membuat Pagination Untuk Pencarian tp pencarian berdasarkan tgl, nah supaya kolom textbox bisa terisi tanggal otomatis mengikuti pc, akan tetapi bisa berubah saat kita mengetikan tgl lainnya dan pagingnya bs mengikuti tgl yg saya pilih
<form method="GET" action="">
<div><label for="tgl_awal">Dari Tanggal</label>
	<input type="text" id="tgl_awal" name="tgl_awal" readonly="readonly" value="">&nbsp;&nbsp;
	<label for="tgl_akhir">Sampai Dengan Tanggal</label>
	<input type="text" id="tgl_akhir" name="tgl_akhir" readonly="readonly" value="">
</div><br>
	
	<input type="submit" value="search" name="search">
</form>

<?php
mysql_connect ("localhost", "root", "87654321");
mysql_select_db ("anggota");

$dataPerPage = 10;
if(isset($_GET['page']))
{
    $noPage = $_GET['page'];
}
else $noPage = 1;
$offset = ($noPage - 1) * $dataPerPage;

$where = '';
if(isset($_GET['search'])){
 
	$tgl_awal= $_GET['tgl_awal'];
	$tgl_akhir= $_GET['tgl_akhir'];
 
	$where .= " WHERE tgl_lulus BETWEEN '$tgl_awal' AND '$tgl_akhir' LIMIT $offset, $dataPerPage";
	$where1 .= " WHERE tgl_lulus BETWEEN '$tgl_awal' AND '$tgl_akhir'";
 	$query = "SELECT * FROM mahasiswa" .$where;
 	$result = mysql_query($query) or die(mysql_error());}

else {
	$where .= " WHERE tgl_lulus = CURDATE() LIMIT $offset, $dataPerPage";
	$where1 .= " WHERE tgl_lulus = CURDATE()";
	$query = "SELECT * FROM mahasiswa" .$where;
	$result = mysql_query($query) or die(mysql_error());}

echo "<table border=1>
	<tr>";
		echo "<th>Nama</font></th>";
		echo "<th>Hobi</font></th>";
        echo "<th>Tanggal</font></th>";
		echo "</tr>";
while($row1= mysql_fetch_array($result))
	{
 
	echo "<tr>";
		echo "<td>" .$row1['nama']. "</font></td>";
		echo "<td>" .$row1['hobi']. "</font></td>";
		echo "<td>" .$row1['tgl_lulus']. "</font></td>";
	echo "</tr>";}
	echo "</table>";

$qp="SELECT Count(*) AS jumData FROM mahasiswa".$where1;
$hasil= mysql_query($qp);
$data = mysql_fetch_array($hasil);
 
$jumData = $data['jumData'];
 
$jumPage = ceil($jumData/$dataPerPage);
 
//bentuk url paramater menggunakan informasi dari $_GET
$params = $_GET;
unset($params['page']);
$urlParam = $params ? '&'.http_build_query($params) : '';
 
if ($noPage > 1) echo  "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1).$urlParam."'>Prev</a>";
// memunculkan nomor halaman dan linknya
for($page = 1; $page <= $jumPage; $page++)
{
         if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
         {
            if (($showPage == 1) && ($page != 2)) echo "...";
            if (($showPage != ($jumPage - 1)) && ($page == $jumPage)) echo "...";
            if ($page == $noPage) echo " <b>".$page."</b> ";
            else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page.$urlParam."'>".$page."</a> ";
            $showPage = $page;
         }
}
// menampilkan link next
if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1).$urlParam."'>Next</a>";

?>
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Aug 4, 2013 · 0 Suka · 0 Tidak Suka
apa seperti ini:
<form method="GET" action="">
<div><label for="tgl_awal">Dari Tanggal</label>
	<input type="text" id="tgl_awal" name="tgl_awal" value="<?php echo $date['Y-m-d']?>">&nbsp;&nbsp;
	<label for="tgl_akhir">Sampai Dengan Tanggal</label>
	<input type="text" id="tgl_akhir" name="tgl_akhir" value="<?php echo $date['Y-m-d']?>">
</div><br>
 
	<input type="submit" value="search" name="search">
</form>