1.Pertama buat koneksi.php<?php
$host = "localhost";
$username = "root";
$password = "123";
$database = db_hrd;
$conn = mysql_connect($host,$username,$password);
if (!$conn) die ("Gagal Melakukan Koneksi");
mysql_select_db($database,$conn) or die ("Database Tidak Diketemukan di Server");
?>
2.lalu buat index.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Absen</title>
<script type="text/javascript" src="jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.11.custom.min.js"></script>
<script type="text/javascript" src="jquery.ui.datepicker-id.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.11.custom.css" />
<script type="text/javascript">
$(document).ready(function() {
$("#tanggal1").datepicker({
dateFormat : "dd-mm-yy",
changeMonth: true,
changeYear: true,
yearRange: "-100:+0",
showon: "button",
buttonText: "menampilkan date picker",
buttonImage: "calendar.gif",
buttonImageonly: true
});
});
</script>
</head>
<body>
<form method="post" action="cari.php">
<? $tangg=date('d-m-Y'); ?>
Tanggal Masuk :<input value="<? echo $tangg ?>" id="tanggal1"name="tanggal1"/>
<table border="1">
<th colspan="3">Kriteria Pencarian</th>
<tr>
<td><input type="radio" value="nama" name="search" checked="checked"/>Nama</td>
<td><input type="radio" value="dep" name="search" />Dep</td>
<td><input type="radio" value="nip" name="search" />NIP</td>
<td><input type="text" name="cari" value="Cari.." onclick="this.value=''" /></td>
<td><input type="submit" value="Tampilkan"/></td>
</tr>
</table>
</form><hr />
</body>
</html>
2.lalu buat cari.php<?
include"koneksi.php";
$kri=$_POST['search'];
$t=$_POST['tanggal1'];
$tgl= substr($t,-4,4) . substr($t,2,3) .'-'. substr($t,0,2);
$tanggal=substr($t,0,2);
$bulan=substr($t,3,2);
$tahun=substr($t,-4,4);
$txt=$_POST['cari'];
if($kri=="nama"){
include"index.php";
?>
<table border="1" cellspacing="0" cellpadding="0" vspace="0">
<tr>
<td>NIP</td>
<td>Nama</td>
<td>Departement</td>
<td>Jenis Kelamin </td>
<td>Kehadiran </td>
<td>Jenis </td>
<td>Keterangan </td>
</tr>
<?
$sql=mysql_query("SELECT * FROM tabel_karyawan WHERE Nama LIKE '%$txt%'")or die(mysql_error());
if(mysql_num_rows($sql)==0){
?><script language="javascript">alert("Data Tidak Ada");</script>
<meta http-equiv="refresh" content="0;url=index.php"><?
}else{
while($res=mysql_fetch_array($sql)){
$nik=$res['NIK'];
$abs=mysql_query("SELECT * FROM view_absesn WHERE tanggal=$tgl")or die(mysql_error());
$sul=mysql_fetch_array($abs);
$nk=mysql_query("select NIK from tabel_absesn WHERE tanggal=$tgl")or die(mysql_error());
$nkh=mysql_fetch_array($nk);
$absen=$nkh['absen'];
?>
<tr onmouseover="this.bgColor='#00FFFF'" onmouseout="this.bgColor='#FFFFFF'">
<td> <? echo $res['NIP']; ?></td>
<td><? echo $res['Nama']; ?></td>
<td><? echo $res['dept']; ?></td>
<td align="center"><? echo $res['jk']; ?></td>
<td align="center">√</td>
<td align="center">-</td>
<td align="center">-</td>
<form action="absen.php" method="post" target="POPUPW" onsubmit="POPUPW = window.open('about:blank','POPUPW','width=550,height=250');" id="dialog-link" class="ui-state-default ui-corner-all">
<input type="hidden" value="<? echo $tgl; ?>" name="tgl" />
<input type="hidden" value="<? echo $tanggal; ?>" name="tanggal" />
<input type="hidden" value="<? echo $bulan; ?>" name="bulan" />
<input type="hidden" value="<? echo $tahun; ?>" name="tahun" />
<input type="hidden" value="<? echo $res['NIK']; ?>" name="nik" />
<input type="hidden" value="<? echo $res['Nama']; ?>" name="nama" />
<input type="hidden" value="<? echo $res['dept']; ?>" name="dept" />
<input type="hidden" value="<? echo $res['jk']; ?>" name="jk" />
<td><input type="submit" name="absen" value="Absen" onclick="return popitup('absen.php')"/></td>
</form>
</tr>
<? } ?>
</table>
<? }
}elseif($kri=="dep"){
include"index.php";
?>
<table border="1" cellspacing="0" cellpadding="0" vspace="0">
<tr>
<td>NIP</td>
<td>Nama</td>
<td>Departement</td>
<td>Jenis Kelamin </td>
<td>Kehadiran </td>
<td>Jenis </td>
<td>Keterangan </td>
</tr>
<?
$sql=mysql_query("SELECT * FROM tabel_karyawan WHERE dept LIKE '$txt%'")or die(mysql_error());
if(mysql_num_rows($sql)==0){
?><script language="javascript">alert("Data Tidak Ada");</script>
<meta http-equiv="refresh" content="0;url=index.php"><?
}else{
while($res=mysql_fetch_array($sql)){
$nik=$res['NIK'];
$abs=mysql_query("SELECT * FROM tabel_absesn WHERE tanggal=$tgl")or die(mysql_error());
$sul=mysql_fetch_array($abs);
$nk=mysql_query("select NIK from tabel_absesn WHERE tanggal=$tgl")or die(mysql_error());
$nkh=mysql_fetch_array($nk);
$absen=$nkh['absen'];
?>
<tr onmouseover="this.bgColor='#00FFFF'" onmouseout="this.bgColor='#FFFFFF'">
<td><? echo $res['NIP']; ?></td>
<td><? echo $res['Nama']; ?></td>
<td><? echo $res['dept']; ?></td>
<td align="center"><? echo $res['jk']; ?></td>
<td align="center">√</td>
<td align="center">-</td>
<td align="center">-</td>
<form action="absen.php" method="post" target="POPUPW" onsubmit="POPUPW = window.open('about:blank','POPUPW','width=550,height=300');">
<input type="hidden" value="<? echo $tgl; ?>" name="tgl" />
<input type="hidden" value="<? echo $tanggal; ?>" name="tanggal" />
<input type="hidden" value="<? echo $bulan; ?>" name="bulan" />
<input type="hidden" value="<? echo $tahun; ?>" name="tahun" />
<input type="hidden" value="<? echo $res['NIK']; ?>" name="nik" />
<input type="hidden" value="<? echo $res['Nama']; ?>" name="nama" />
<input type="hidden" value="<? echo $res['dept']; ?>" name="dept" />
<input type="hidden" value="<? echo $res['jk']; ?>" name="jk" />
<td><input type="submit" name="absen" value="Absen" onclick="return popitup('absen.php')"/></td>
</form>
</tr>
<? } ?>
</table>
<? }
}elseif($kri=="nip"){
include"index.php";
?>
<table border="1" cellspacing="0" cellpadding="0" vspace="0">
<tr>
<td>NIP</td>
<td>Nama</td>
<td>Departement</td>
<td>Jenis Kelamin </td>
<td>Kehadiran </td>
<td>Jenis </td>
<td>Keterangan </td>
</tr>
<?
$sql=mysql_query("SELECT * FROM tabel_karyawan WHERE NIP LIKE '$txt%'")or die(mysql_error());
if(mysql_num_rows($sql)==0){
?><script language="javascript">alert("Data Tidak Ada");</script>
<meta http-equiv="refresh" content="0;url=index.php"><?
}else{
while($res=mysql_fetch_array($sql)){
$nik=$res['NIK'];
$abs=mysql_query("SELECT * FROM tabel_absesn WHERE NIK LIKE '%$nik%' AND tanggal='$tgl'")or die(mysql_error());
$sul=mysql_fetch_array($abs)
?>
<tr onmouseover="this.bgColor='#00FFFF'" onmouseout="this.bgColor='#FFFFFF'">
<td><? echo $res['NIP']; ?></td>
<td><? echo $res['Nama']; ?></td>
<td><? echo $res['dept']; ?></td>
<td align="center"><? echo $res['jk']; ?></td>
<td align="center">√</td>
<td align="center">-</td>
<td align="center">-</td>
<form action="absen.php" method="post" target="POPUPW" onsubmit="POPUPW = window.open('about:blank','POPUPW','width=550,height=300');">
<input type="hidden" value="<? echo $tgl; ?>" name="tgl" />
<input type="hidden" value="<? echo $tanggal; ?>" name="tanggal" />
<input type="hidden" value="<? echo $bulan; ?>" name="bulan" />
<input type="hidden" value="<? echo $tahun; ?>" name="tahun" />
<input type="hidden" value="<? echo $res['NIK']; ?>" name="nik" />
<input type="hidden" value="<? echo $res['Nama']; ?>" name="nama" />
<input type="hidden" value="<? echo $res['dept']; ?>" name="dept" />
<input type="hidden" value="<? echo $res['jk']; ?>" name="jk" />
<td><input type="submit" name="absen" value="Absen" onclick="return popitup('absen.php')"/></td>
</form>
</tr>
<? } ?>
</table>
<? }
}else{
echo"Gagal Mencari";
?>
<meta http-equiv="refresh" content="1;url=index.php">
<?
}
?>
Semoga bermanfaat