ceritanya gini gan saya punya data absensi, saya bingung cara untuk editnya, karena pada keterangan kehadiranya menggunakan cekbox,,, saya minta bantuan agan-agan untuk membuat edit datanya,
nama tabelnya absensi
filenya kd_absensi,nis,kelas,keterangan,tanggal,selesai
ini kode tampil datanya.
<?php include "conn.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>Administrator dan User Area</title>
</head>
<body leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" bgcolor="#ffffff">
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="83%">
<tr>
<td width="50%" background="../gambar/bg.gif"><img src="../gambar/px1.gif" width="1" height="1" alt="" border="0"></td>
<td valign="bottom" background="../gambar/bg_left.gif"><img src="../gambar/bg_left.gif" alt="" width="17" height="16" border="0"></td>
<td bgcolor="#FFFFFF"><table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FFFFFF"><?php include "header.php"; ?></td>
</tr>
<tr>
<td background="../gambar/fon02.gif" height="34"><div align="center"></div></td>
</tr>
</table>
<p align="center" class="px">
<?php include "menu.php"; ?>
<table width="671" border="0" align="center" cellpadding="1" cellspacing="0">
</p>
<p align="center"> </p>
<td width="515"><table width="510" border="0" align="center">
<tr>
<td valign="top">
<h2 class="title"><div align="center">LAPORAN ABSENSI KELAS</div></h2>
<?php
//untuk koneksi database
include "conn.php";
//untuk menantukan tanggal awal dan tanggal akhir data di database
$min_tanggal=mysql_fetch_array(mysql_query("select min(tanggal) as min_tanggal from absensi"));
$max_tanggal=mysql_fetch_array(mysql_query("select max(tanggal) as max_tanggal from absensi"));
?>
<form action="" method="post" name="postform">
<table width="435" border="0">
<tr>
<td width="111">Kelas</td>
<td colspan="2"><select name="kelas">
<option value="0" selected="selected">Pilih Kelas</option>
<?php
$query=mysql_query("select * from kelas order by kelas asc",$koneksi);
while($row=mysql_fetch_array($query))
{
?><option value="<?php echo $row['kelas']; ?>"><?php echo $row['kelas']; ?></option><?php
}
?>
</select></td>
</tr>
<tr>
<td>Tanggal Awal</td>
<td colspan="2"><input type="text" name="tanggal_awal" size="15" value="<?php echo $min_tanggal['min_tanggal'];?>"/>
<a href="javascript:void(0)" onClick="if(self.gfPop)gfPop.fPopCalendar(document.postform.tanggal_awal);return false;" ><img name="popcal" align="absmiddle" src="calender/calbtn.gif" width="34" height="29" border="0" alt=""></a>
</td>
</tr>
<tr>
<td>Tanggal Akhir</td>
<td colspan="2"><input type="text" name="tanggal_akhir" size="15" value="<?php echo $max_tanggal['max_tanggal'];?>"/>
<a href="javascript:void(0)" onClick="if(self.gfPop)gfPop.fPopCalendar(document.postform.tanggal_akhir);return false;" ><img name="popcal" align="absmiddle" src="calender/calbtn.gif" width="34" height="29" border="0" alt=""></a>
</td>
</tr>
<tr>
<td><input type="submit" value="Tampilkan Data" name="cari"></td>
<td colspan="2"> </td>
</tr>
</table>
</form>
<p>
<?php
//di proses jika sudah klik tombol cari
if(isset($_POST['cari'])){
//menangkap nilai form
$kelas=$_POST['kelas'];
$tanggal_awal=$_POST['tanggal_awal'];
$tanggal_akhir=$_POST['tanggal_akhir'];
if(empty($kelas) and empty($tanggal_awal) and empty($tanggal_akhir)){
//jika tidak menginput apa2
$query=mysql_query("select * from absensi");
$jumlah=mysql_fetch_array(mysql_query("select sum(keterangan) as total from absensi"));
}else{
?><i><b>Informasi : </b> Pencarian Data Absensi <b><?php echo ucwords($_POST['kelas']);?></b> dari tanggal <b><?php echo $_POST['tanggal_awal']?></b> sampai dengan tanggal <b><?php echo $_POST['tanggal_akhir']?></b></i><?php
$query=mysql_query("select * from absensi where kelas='$kelas' and tanggal between '$tanggal_awal' and '$tanggal_akhir'");
$jumlah=mysql_fetch_array(mysql_query("select sum(keterangan) as total from absensi where kelas='$kelas' and tanggal between '$tanggal_awal' and '$tanggal_akhir'"));
}
?>
</p>
<table class="datatable">
<td width="515"><table width="510" border="1" align="center">
<tr bgcolor="#FFFF99">
<th width="10">No</th>
<th width="90">Nis</th>
<th width="40">Kelas</th>
<th width="80">Tanggal Absensi</th>
<th width="30">Ket</th>
<th width="30">Aksi</th>
</tr>
<?php
//untuk penomoran data
$no=0;
//menampilkan data
while($row=mysql_fetch_array($query)){
?>
<tr>
<td><div align="center"><?php echo $no=$no+1; ?></td><td><?php echo $row['nis']; ?></td><td><div align="center"><?php echo $row['kelas']; ?></td><td><div align="center"><?php echo $row['tanggal'];?></td><td><div align="center"><?php echo $row['keterangan'];?></div></td><td div align="center"><a href="<?php echo "hapus_absensi.php?kd_absensi=$row[kd_absensi]";?>" onclick="return confirm('Apakah anda yakin akan menghapus data ini?')">Hapus</a> | <a href="editabsensi.php?kd_absensi=$row[kd_absensi]";?>Edit</a></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center">
<?php
//jika data tidak ditemukan
if(mysql_num_rows($query)==0){
echo "<font color=red><blink>Data Tidak Ada!</blink></font>";
}
?>
</td>
</tr>
</table>
</table>
<?php
}else{
unset($_POST['cari']);
}
?>
<iframe width=174 height=189 name="gToday:normal:calender/normal.js" id="gToday:normal:calender/normal.js" src="calender/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;">
</iframe>
</body>
</html>
</div>
<iframe width=174 height=189 name="gToday:normal:calender/agenda.js" id="gToday:normal:calender/agenda.js" src="calender/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;">
</iframe>
</table><div align="center"><a href="absensi.php">Kembali</a> | <a href="cetak_absensi.php">Cetak</a>
<p> </p>
<div class="px" align="center"><img src="../gambar/bot01.jpg" width="780" height="9" alt="" border="0"></div>
<table border="0" cellspacing="0" cellpadding="0" width="780" align="center">
<tr>
<td><p align="center">
<?php include "footer.php"; ?>
</p></td>
<td height="50">
<p class="bot"> </p>
</td>
</tr>
</table><tr></table>
<td valign="bottom" background="../gambar/bg_right.gif"><img src="../gambar/bg_right.gif" alt="" width="17" height="16" border="0"></td>
<td width="50%" background="../gambar/bg.gif"><img src="../gambar/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
</table>
lalu ini code form editnya
<form name="form1" method="post" action="aksi_edit_absen.php">
<table width="400" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFF99" bgcolor="#FF0000">
<tr bgcolor="#FFFFCC">
<td height="50" colspan="2"><div align="center">EDIT DATA</div></td>
</tr>
<?php
mysql_connect('localhost','root','1');
mysql_select_db('smabukit');
$sqlTampil="select * from absensi Where kd_absensi='$_GET[kd_absensi]'";
$qryTampil=mysql_query($sqlTampil);
$dataTampil=mysql_fetch_array($qryTampil);
?>
<tr bgcolor="#FFFFFF">
<td height="40">Nis </td>
<td>:
<input name="nis" type="text" id="nis" value="<?php echo $dataTampil['nis']; ?>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">kelas </td>
<td>:
<input name="nama" type="text" id="nama" value="<?php echo $dataTampil['kelas']; ?>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">tanggal</td>
<td>:
<input name="alamat" type="text" id="alamat" value="<?php echo $dataTampil['tanggal']; ?>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td>Keterangan</td>
<td>: <input type="radio" name="keterangan" value="h" <?php if($baris['keterangan']=="h"){ echo "checked";}?> > Hadir
<input type="radio" name="keterangan" value="s" <?php if($baris['keterangan']=="s"){ echo "checked";}?> >Sakit
<input type="radio" name="keterangan" value="i" <?php if($baris['keterangan']=="i"){ echo "checked";}?> >Ijin
<input type="radio" name="keterangan" value="a" <?php if($baris['keterangan']=="a"){ echo "checked";}?> >Alfa</td>
</tr>
<td> </td>
<td height="50"><input type="submit" name="Submit" value="Simpan"></td>
</tr>
</table> <div align="center"><input type="checkbox" name="selesai" value="yes" />Tandai Kelas Sudah Selesai
</form>
ini kode aksi_edit_abses nya
<?php
$nis = $_POST['nis'];
$kelas = $_POST['kelas'];
$tanggal = $_POST['tanggal'];
$keterangan = $_POST['keterangan'];
//koneksi database
$conn = mysql_connect("localhost","root","1");
mysql_select_db("smabukit");
$query = "update absens set (nis,kelas,keterangan,tanggal,selesai) values('$nis','$kelas','$tanggal','yes')",$koneksi);
$hasil = mysql_query($query);
if($hasil){
echo "Data siswa telah disimpan";
}else{
echo "Error! gagal menyimpan data siswa:".mysql_error();
}
?>
mohon bantuanya gan dimana kesalahannya,,,,,,,????????