Saya mau tanya misal dari combobox ada inputan berupa jumlah uang dan secara otomatis di textfield muncul 2% dari inputan tersebut dan sekaligus terbilangnya, bagaimana code nya menggunakan javascript?
Silahkan login untuk menjawab!
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">&nbsp;</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">&nbsp;</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>&nbsp;</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">&nbsp;</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 &nbsp;&nbsp;
				<input type="radio" name="keterangan" value="s" <?php if($baris['keterangan']=="s"){ echo "checked";}?> >Sakit &nbsp;&nbsp;
				<input type="radio" name="keterangan" value="i" <?php if($baris['keterangan']=="i"){ echo "checked";}?> >Ijin &nbsp;&nbsp;
				<input type="radio" name="keterangan" value="a" <?php if($baris['keterangan']=="a"){ echo "checked";}?> >Alfa</td>
			</tr> 
          <td>&nbsp;</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,,,,,,,????????
Silahkan login untuk menjawab!
mas saya membuat inputan dengan dropdown dibawah ini
<select name="condition4" id="condition4" style="width:70px" >
  <option value=""></option>
  <option value="Good">Good</option>
  <option value="Fail">Fail</option>
   </select>

bagaimana caranya agar inputan diatas berhasil masuk ke databasenya? terimakasih

ini script input.php
<form action="aksi_tanah_hitam.php" method="post">
<h1>TANAH HITAM</h1>
<table width="800" border="1">
  <tr>
    <td width="150" align="center">Equipment</td>
    <td align="center" width="150">Merk</td>
    <td align="center" width="150">Type</td>
    <td width="150" align="center">Serial Number</td>
    <td align="center" width="80">Condition</td>
    <td align="center" width="150">Note</td>
    <td width="100" align="center">Qty</td>
  </tr>
  <tr>
    <td> <input name="equipment" type="text" id="equipment" width="200"  /></td><!--kolom satu Equipment------------------------>
    <td><input name="merk" type="text" id="merk" width="200"  /></td><!-- Merk kolom satu ------------------->
    <td><input name="type" type="text" id="type" width="200"  /> </td><!-- Type kolom satu ------------------->
    <td><input name="serial" type="text" id="serial" width="200"  /></td><!-- Serial Number kolom satu ------------------->
     <td><select name="condition" id="condition" style="width:70px" >
  <option value=""></option>
  <option value="Good">Good</option>
  <option value="Fail">Fail</option>
   </select></td><!-- Serial Number kolom satu ------------------->
    <td><input name="note" type="text" id="note" width="200"  /></td><!-- Note kolom satu ------------------->
    <td><input name="qty" type="text" id="qty" width="200"  /></td><!-- Qty kolom satu ------------------->
  </tr>

Lihat semua 1 jawaban

Silahkan login untuk menjawab!

Minta Bantuannya Gan

Adies · Dec 13, 2013
gimana caranya agar saya bisa menyimpan data dengan chekbox...
ceritanya begini,, sya buat absensi siswa, proses absennya perkelas dan untuk keterangan kehadiranya di pilih dengan chekbox atau cheklis,,, yang saya mau tanya gimana caranya menyimpan data yang di ceklis tersebut ke dalam database? terima kasih sebelumnya...
ini kode absensi.php
<?php
session_start();

if (isset($_SESSION['level']) && isset($_SESSION['username']))
{
   if ($_SESSION['level'] == "admin")
   {
?>

<!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">
        <tr>
          <td width="549"><table width="598" border="0" align="center">
		<tr>
              <td width="518"><div align="center">
                <h2><strong>INPUT NILAI SISWA</strong></h2>
	<div align="center"><a href="nilai_siswa.php">Laporan Nilai</a> </div></td>
              </div></td>
<div class="post">
<div class="entry">
<table width="500" border="1" align="center" cellpadding="1" cellspacing="0">
		<tr bgcolor="#FFFF99">
			<th>No</th><th>Nama Kelas</th><th>Jumlah Siswa</th><th>Aksi</th>
		</tr>
		<?php 
		include "conn.php";
		$kelas=mysql_query("select * from kelas order by kelas asc",$koneksi);
		//untuk mencari jumlah
		echo "Jumlah Kelas : ".$jumlah_kelas=mysql_num_rows($kelas);
		echo " >> Jumlah Siswa : ".$jumlah_siswa=mysql_num_rows(mysql_query("select * from tblsiswa",$koneksi));
		echo "<br><br>";
		
		while($row=mysql_fetch_array($kelas)){
			//mencari jumlah siswa di masing-masing kelas
			$siswa=mysql_query("select * from tblsiswa where kelas='$row[kelas]'",$koneksi);
			$jumlah=mysql_num_rows($siswa);
			?>
			<tr>
				<td align="center"><?php echo $c=$c+1; ?></td><td align="center"><?php echo $row['kelas']; ?></td><td align="center"><?php echo $jumlah;?> Orang</td>
				<td align="center"><a href="input_absensi.php?kelas=<?php echo $row['kelas'];?>">Absensi</a></td>
			</tr>
			<?php
		}
		?>
		</table>
		</p>
  </div>
      </tr>
    </table>
    <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">&nbsp;</p>
	</td>
</tr>
</table>
	</td>
	<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>

</body>
</html>
<?
}
   else
   {
       // jika levelnya bukan admin, tampilkan pesan
       echo "<script type='text/javascript'>
{
if(alert('Sorry gank!! Anda tidak berhak mengakses halaman ini karena bukan admin.')){document.location='login.php';}
}

</script>";
   }
}
else
{
   echo "<script type='text/javascript'>
{
if(alert('Login Dulu dong Frend!!')){document.location='login.php';}
}

</script>";
}
?>

ini kode input_absensi.php
<?php
session_start();

if (isset($_SESSION) && isset($_SESSION))
{
if ($_SESSION == "admin")
{

include "conn.php";
$kelas=$_GET;
$query=mysql_fetch_array(mysql_query("select * from kelas where kelas='$kelas'"));
?>
<!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">&nbsp;</p>
</td>
<td width="515"><table width="510" border="0" align="center">

<tr>
<td valign="top"><h2 align="center"><strong>Nilai Siswa SMA Negeri 1 Bukit </strong></h2>
<div class="post">
<h2 class="title"><a href="#">ABSENSI KELAS <?php echo $query;?></a></h2>
<div class="entry">
<p>
<form action="?page=proses" method="post" name="postform">
<input type="hidden" value="<?php echo $query;?>" name="kelas"/>
<table class="datatable">
<tr>
<td width="24%" align="left" colspan="6">Tanggal : <input type="text" name="tanggal" value="<?php if(empty($_POST)){ echo $tanggal;}else{ echo "$_POST[tgl]$_GET[tgl]"; }?>" size="11"><a href="javascript:void(0)" onClick="if(self.gfPop)gfPop.fPopCalendar(document.postform.tanggal);return false;" ><img name="popcal" align="absmiddle" src="calender/calbtn.gif" width="34" height="29" border="0" alt=""></a></td>
</tr>
<table width="644" border="1" align="center" cellpadding="1" cellspacing="0">
<tr bgcolor="#FFFF99">
<td width="30"><div align="center"><strong>No</strong></div></td>
<td width="181"><div align="center"><strong>Nama Siswa</strong></div></td>
<td width="74"><div align="center"><strong>Hadir</strong></div></td>
<td width="50"><div align="center"><strong>Sakit</strong></div></td>
<td width="70"><div align="center"><strong>Ijin</strong></div></td>
<td width="68"><div align="center"><strong>Alfa</strong></div></td>
</tr>
<?php
//penting buat kasih nilai awal cekbox
$no=0;

$query=mysql_query("select * from tblsiswa where kelas='$kelas'");
while($row=mysql_fetch_array($query)){
?>
<tr>
<td><?php echo $c=$c+1;?></td><td><?php echo $row;?></td>
<td align="center">
<?php
echo "<input type=checkbox name=hadir[] value=$row[nis] id='$no'>";
$no++;
?>
</td>
<td align="center">
<?php
echo "<input type=checkbox name=sakit[] value=$row[nis] id=$no>";
$no++;
?>
</td>
<td align="center">
<?php
echo "<input type=checkbox name=ijin[] value=$row[nis] id=$no>";
$no++;
?>
</td>
<td align="center">
<?php
echo "<input type=checkbox name=alfa[] value=$row[nis] id=$no>";
$no++;
?>
</td>
</tr>
<?php
}

echo "
<tr>
<td></td>
<td></td>
<td align=center>
<input type='button' name='pilih' onclick='for (i=0;i<$no;i++){document.getElementById(i).checked=true;}' value='Check All'>
</td>
<td align=center>
<input type='button' name='pilih' onclick='for (i=0;i<$no;i++){document.getElementById(i).checked=false;}' value='Uncheck All'>
</td>
<td></td>
<td></td>
</tr>";
?>
</table>
<br />
<input type="checkbox" name="selesai" value="yes" />Tandai Kelas Selesai
<br /><br />
<input type="submit" value="Submit" /> <a href="absensi.php">Kembali</a>
</form>
</p>
</div>
</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>
<p>&nbsp;</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">&nbsp;</p>
</td>
</tr>
</table><tr></table>
</td>
<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>

</body>
</html>
<?php
}
else
{
// jika levelnya bukan admin, tampilkan pesan
echo "<script type='text/javascript'>
{
if(alert('Sorry gank!! Anda tidak berhak mengakses halaman ini karena bukan admin.')){document.location='login.php';}
}

</script>";
}
}
else
{
echo "<script type='text/javascript'>
{
if(alert('Login Dulu dong Frend!!')){document.location='login.php';}
}

</script>";
}
?>

ini kode proses.php
<?php
include "conn.php";
$kelas=$_POST;
$tanggal=$_POST;

if(isset($_POST)){

if(!empty($_POST)){
//parameter
$nis=$_POST;
$jumlah=count($nis);

for($i=0;$i<$jumlah;$i++){
$hadir=mysql_query("insert into absensi(nis,kelas,keterangan,tanggal,selesai) values('$nis[$i]','$kelas','h','$tanggal','yes')",$koneksi);
}

?>
<script language="javascript">document.location.href="?page=view_absensi&kelas=<?php echo $kelas;?>&tanggal=<?php echo $tanggal;?>";</script>
<?php
}

if(!empty($_POST)){
//parameter
$nis=$_POST;
$jumlah=count($nis);


for($i=0;$i<$jumlah;$i++){
$hadir=mysql_query("insert into absensi(nis,kelas,keterangan,tanggal,selesai) values('$nis[$i]','$kelas','s','$tanggal','yes')",$koneksi);
}

?>
<script language="javascript">document.location.href="?page=view_absensi&kelas=<?php echo $kelas;?>&tanggal=<?php echo $tanggal;?>";</script>
<?php
}

if(!empty($_POST)){
//parameter
$nis=$_POST;
$jumlah=count($nis);


for($i=0;$i<$jumlah;$i++){
$hadir=mysql_query("insert into absensi(nis,kelas,keterangan,tanggal,selesai) values('$nis[$i]','$kelas','i','$tanggal','yes')",$koneksi);
}

?>
<script language="javascript">document.location.href="?page=view_absensi&kelas=<?php echo $kelas;?>&tanggal=<?php echo $tanggal;?>";</script>
<?php
}

if(!empty($_POST)){
//parameter
$nis=$_POST;
$jumlah=count($nis);


for($i=0;$i<$jumlah;$i++){
$hadir=mysql_query("insert into absensi(nis,kelas,keterangan,tanggal,selesai) values('$nis[$i]','$kelas','a','$tanggal','yes')",$koneksi);
}

?>
<script language="javascript">document.location.href="?page=view_absensi&kelas=<?php echo $kelas;?>&tanggal=<?php echo $tanggal;?>";</script>
<?php
}
}else{
unset($_POST);
?><script language="javascript">document.location.href="?page=input_absensi&kelas=<?php echo $kelas;?>&tanggal=<?php echo $tanggal;?>";</script><?php
}
?>
Silahkan login untuk menjawab!
script tengahnya seperti yang saya insert. saya sudah berhasil membuat checkboxnya yang berada dikolom ambil. data telah berhasil ditampilkan berdasarkan database dengan tabel matakuliah. saya ingin membuat submit dimana sebelahnya ada kota kecil yang menghitung jumlah sks yang diambil berdasarkan banyak sks yang ada dikolom sks. kemudian ketika submitnya diklik maka akan langsung menampilkan data yang dipilih melalui checkbox. jadi, tombol submti fungsinya langsung save pilihan yang dicheckbo sekalian menampilkan. bantu y master2. maaf, saya newbie di php :(
      	<!--  membuat tabel ..................................................................................... -->
        <form id="mainform" action="">
        <table border="0" width="63%" cellpadding="0" cellspacing="0" id="product-table">
        <tr>
            <th width="13%" class="table-header-repeat line-left minwidth-1"><a href="">Nomor</a>	</th>
            <th width="32%" class="table-header-repeat line-left minwidth-1"><a href="">Kode MK</a></th>
            <th width="17%" class="table-header-options line-left"><a href="">Nama Mata Kuliah</a></th>
            <th width="17%" class="table-header-options line-left"><a href="">Dosen</a></th>
			<th width="16%" class="table-header-options line-left"><a href="">Jadwal</a></th>
			<th width="25%" class="table-header-repeat line-left minwidth-1"><a href="">SKS</a></th>
            <th width="32%" class="table-header-repeat line-left minwidth-1"><a href="">Ambil</a></th>
        </tr>
 
        <?php
		$view=mysql_query("select * from matakuliah");
		$no=0;
		while($row=mysql_fetch_array($view)){
		?>	
		<tr>
            <td><?php echo $no=$no+1;?></td>
            <td><?php echo $row['KodeMK'];?></td>
            <td><?php echo $row['nama_mk'];?></td>
			<td><?php echo $row['Dosen'];?></td>  
			<td><?php echo $row['Jadwal'];?></td> 
			<td><?php echo $row['SKS'];?></td>
            <td><input type="checkbox" name='cek[$cekno]' id=id$no value='$row[KodeMK]'> </td> 
          </td>
        </tr>
		<?php
		}
		?>
        </table>
        <!--  akhir tabel................................... --> 
        </form>
Silahkan login untuk menjawab!
Gini master" semua ane kan bikin theme option tuh
nah waktu upload 2"nya tu lancar jaya luar biasa
tapi ketika ane delete salah satu image...eh malah imagenya ke delete semua...
tolong bantuin ane gan...gmn caranya agar ketika ane delete satu image ygke delete ya itu saja..ndak semua ke delete..

Tolong Master" semua

ini functionnya
<?php
function wptuts_get_default_options() {
	$options = array(
		'image1' => '',
		'image2' => ''
	);
	return $options;
}

function wptuts_options_init() {
     $wptuts_options = get_option( 'theme_wptuts_options' );

	 // Are our options saved in the DB?
     if ( false === $wptuts_options ) {
		  // If not, we'll save our default options
          $wptuts_options = wptuts_get_default_options();
		  add_option( 'theme_wptuts_options', $wptuts_options );
     }

     // In other case we don't need to update the DB
}
// Initialize Theme options
add_action( 'after_setup_theme', 'wptuts_options_init' );

function wptuts_options_setup() {
	global $pagenow;
	if ('media-upload.php' == $pagenow || 'async-upload.php' == $pagenow) {
		// Now we'll replace the 'Insert into Post Button inside Thickbox'
		add_filter( 'gettext', 'replace_thickbox_text' , 1, 2 );
	}
}
add_action( 'admin_init', 'wptuts_options_setup' );

function replace_thickbox_text($translated_text, $text ) {
	if ( 'Insert into Post' == $text ) {
		$referer = strpos( wp_get_referer(), 'wptuts-settings' );
		if ( $referer != '' ) {
			return __('I want this to be my image!', 'wptuts' );
		}
	}

	return $translated_text;
}

// Add "WPTuts Options" link to the "Appearance" menu
function wptuts_menu_options() {
	//add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);
     add_theme_page('Theme Options', 'Theme Options', 'edit_theme_options', 'wptuts-settings', 'wptuts_admin_options_page');
}
// Load the Admin Options page
add_action('admin_menu', 'wptuts_menu_options');

function wptuts_admin_options_page() {
	?>
		<!-- 'wrap','submit','icon32','button-primary' and 'button-secondary' are classes
		for a good WP Admin Panel viewing and are predefined by WP CSS -->

		<div class="wrap">

			<div id="icon-themes" class="icon32"><br /></div>

			<h2><?php _e( 'Theme Options', 'wptuts' ); ?></h2>

			<!-- If we have any error by submiting the form, they will appear here -->
			<?php settings_errors( 'wptuts-settings-errors' ); ?>

			<form id="form-wptuts-options" action="options.php" method="post" enctype="multipart/form-data">

				<?php
					settings_fields('theme_wptuts_options');
					do_settings_sections('wptuts');
				?>

				<p class="submit">
					<input name="theme_wptuts_options[submit]" id="submit_options_form" type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'wptuts'); ?>" />
					<input name="theme_wptuts_options[reset]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults', 'wptuts'); ?>" />
				</p>

			</form>

		</div>
	<?php
}

function wptuts_options_validate( $input ) {

	$default_options = wptuts_get_default_options();
	$valid_input = $default_options;

	$wptuts_options = get_option('theme_wptuts_options');

	$submit = ! empty($input['submit']) ? true : false;
	$reset = ! empty($input['reset']) ? true : false;
	$delete_image1 = ! empty($input['delete_image1']) ? true : false;
	$delete_image2 = ! empty($input['delete_image2']) ? true : false;

	// if($_POST['delete_image1'] == 'Delete image1' && $_POST['delete_image2'] == '') {
	// 	delete_image( $wptuts_options['image1'] );
	// }
	// elseif($_POST['delete_image2'] == 'Delete image2' && $_POST['delete_image1'] == '') {
	// 	delete_image( $wptuts_options['image2'] );

	// }

	if ( $submit ) {

		if($input['image1']){
			if ( $wptuts_options['image1'] != $input['image1']  && $wptuts_options['image1'] != '' ){
			delete_image( $wptuts_options['image1'] );
			// var_dump($input['image1']);
			// die();
			}
			$valid_input['image1'] = $input['image1'];
		}

		if($input['image2']){
			if ( $wptuts_options['image2'] != $input['image2']  && $wptuts_options['image2'] != '' ){
			delete_image( $wptuts_options['image2'] );
			// var_dump($input['image2']);
			// die();
			}

			$valid_input['image2'] = $input['image2'];
		}

		// if ($wptuts_options['image2'] != '' ){
		// 	delete_image( $wptuts_options['image2'] );
		// }

		// $valid_input['image2'] = $input['image2'];

	}
	elseif ( $reset ) {
		delete_image( $wptuts_options['image1'] );
		$valid_input['image1'] = $default_options['image1'];

		delete_image( $wptuts_options['image2'] );
		$valid_input['image2'] = $default_options['image2'];

	}
	elseif ( $delete_image1 ) {
		delete_image( $wptuts_options['image1'] );
		$valid_input['image1'] = '';
	}

	elseif ( $delete_image2 ) {
		delete_image( $wptuts_options['image2'] );
		$valid_input['image2'] = '';
	}

	return $valid_input;
}

function delete_image( $image_url ) {
	global $wpdb;

	// We need to get the image's meta ID..
	$query = "SELECT ID FROM wp_posts where guid = '" . esc_url($image_url) . "' AND post_type = 'attachment'";
	$results = $wpdb -> get_results($query);

	// And delete them (if more than one attachment is in the Library
	foreach ( $results as $row ) {
		wp_delete_attachment( $row -> ID );
	}
}

/********************* JAVASCRIPT ******************************/
function wptuts_options_enqueue_scripts() {
	wp_register_script( 'wptuts-upload', get_template_directory_uri() .'/wptuts-options/js/wptuts-upload.js', array('jquery','media-upload','thickbox') );	

	if ( 'appearance_page_wptuts-settings' == get_current_screen() -> id ) {
		wp_enqueue_script('jquery');

		wp_enqueue_script('thickbox');
		wp_enqueue_style('thickbox');

		wp_enqueue_script('media-upload');
		wp_enqueue_script('wptuts-upload');

	}

}
add_action('admin_enqueue_scripts', 'wptuts_options_enqueue_scripts');

function wptuts_options_settings_init() {
	register_setting( 'theme_wptuts_options', 'theme_wptuts_options', 'wptuts_options_validate' );

	// Add a form section for the image1
	add_settings_section('wptuts_settings_header', __( 'Image Option', 'wptuts' ), 'wptuts_settings_header_text', 'wptuts');

	// Add image1 uploader
	add_settings_field('wptuts_setting_image1',  __( 'Image1', 'wptuts' ), 'wptuts_setting_image1', 'wptuts', 'wptuts_settings_header');

	// Add Current Image Preview
	add_settings_field('wptuts_setting_image1_preview',  __( 'Image1 Preview', 'wptuts' ), 'wptuts_setting_image1_preview', 'wptuts', 'wptuts_settings_header');

	//-------------------image2---------------------------------------------------------------------------------------

	// Add image2 uploader
	add_settings_field('wptuts_setting_image2',  __( 'Image2', 'wptuts' ), 'wptuts_setting_image2', 'wptuts', 'wptuts_settings_header');

	// Add Current Image Preview
	add_settings_field('wptuts_setting_image2_preview',  __( 'Image2 Preview', 'wptuts' ), 'wptuts_setting_image2_preview', 'wptuts', 'wptuts_settings_header');

}
add_action( 'admin_init', 'wptuts_options_settings_init' );

function wptuts_settings_header_text() {
	?>
		<p><?php _e( 'Manage Image Options for Kusa Theme.', 'wptuts' ); ?></p>
	<?php
}

function wptuts_setting_image1_preview() {
	$wptuts_options = get_option( 'theme_wptuts_options' );  ?>
	<div id="upload_image1_preview" style="min-height: 100px;">
		<img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['image1'] ); ?>" />
	</div>
	<?php

}

function wptuts_setting_image1() {
	$wptuts_options = get_option( 'theme_wptuts_options' );
	?>
		<input type="hidden" id="image1_url" name="theme_wptuts_options[image1]" value="<?php echo esc_url( $wptuts_options['image1'] ); ?>" />
		<input id="upload_image1_button" type="button" class="button" value="<?php _e( 'Upload image1', 'wptuts' ); ?>" />
		<?php if ( '' != $wptuts_options['image1'] ): ?>
			<input id="delete_image1_button" name="delete_image1" type="submit" class="button" value="<?php _e( 'Delete image1', 'wptuts' ); ?>" />
			<input type="hidden" id="image1_url" name="image1" value="1" />
		<?php endif; ?>
		<span class="description"><?php _e('Upload an Image for the banner.', 'wptuts' ); ?></span>
	<?php
}

//---------------------image 2----------------------------------------------------------------------------------------------

function wptuts_setting_image2_preview() {
	$wptuts_options = get_option( 'theme_wptuts_options' );  ?>
	<div id="upload_image2_preview" style="min-height: 100px;">
		<img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['image2'] ); ?>" />
	</div>
	<?php

}

function wptuts_setting_image2() {
	$wptuts_options = get_option( 'theme_wptuts_options' );
	?>
		<input type="hidden" id="image2_url" name="theme_wptuts_options[image2]" value="<?php echo esc_url( $wptuts_options['image2'] ); ?>" />
		<input id="upload_image2_button" type="button" class="button" value="<?php _e( 'Upload image2', 'wptuts' ); ?>" />
		<?php if ( '' != $wptuts_options['image2'] ): ?>
			<input id="delete_image2_button" name="delete_image2" type="submit" class="button" value="<?php _e( 'Delete image2', 'wptuts' ); ?>" />
			<input type="hidden" id="image1_url" name="image2" value="2" />
		<?php endif; ?>
		<span class="description"><?php _e('Upload an Image for the banner.', 'wptuts' ); ?></span>
	<?php
}

?>

ini JQuerynya :
jQuery(document).ready(function($){
	$('#upload_image1_button').click(function() {
		//type = image,audio,video,file. If we write it wrong, nothing will appear. type = file by default
		// El tipo no importa, ya que desde hace algunas versiones, el uploader puede subir cualquier tipo de archivo

		// Si no lo hacemos desde un meta box dentro de un post y además WP_DEBUG = true, nos saldrá un error ya que
		// no estará asociado a ningún post

		//tb_show(caption, url, imageGroup)
		// Google: 'ImageGroup tb_show thickbox':
		//The optional imageGroup parameter can also be used to pass in an array of images for a single or multiple image slide show gallery.
		// The problem is that inserting a gallery needs an associated post to work
		tb_show('Upload a image1', 'media-upload.php?referer=wptuts-settings&type=image&TB_iframe=true&post_id=0', false);

		window.send_to_editor = function(html) {
		// html returns a link like this:
		// <a href="{server_uploaded_image_url}"><img src="{server_uploaded_image_url}" alt="" title="" width="" height"" class="alignzone size-full wp-image-125" /></a>
		var image_url = $('img',html).attr('src');

		//alert(html);
		$('#image1_url').val(image_url);
		tb_remove();
		$('#upload_image1_preview img').attr('src',image_url);

		$('#submit_options_form').trigger('click');
		// $('#uploaded_image1').val('uploaded');
		}

		return false;

	});

	$('#upload_image2_button').click(function() {
		//type = image,audio,video,file. If we write it wrong, nothing will appear. type = file by default
		// El tipo no importa, ya que desde hace algunas versiones, el uploader puede subir cualquier tipo de archivo

		// Si no lo hacemos desde un meta box dentro de un post y además WP_DEBUG = true, nos saldrá un error ya que
		// no estará asociado a ningún post

		//tb_show(caption, url, imageGroup)
		// Google: 'ImageGroup tb_show thickbox':
		//The optional imageGroup parameter can also be used to pass in an array of images for a single or multiple image slide show gallery.
		// The problem is that inserting a gallery needs an associated post to work
		tb_show('Upload a image2', 'media-upload.php?referer=wptuts-settings&type=image&TB_iframe=true&post_id=0', false);

		window.send_to_editor = function(html) {
		// html returns a link like this:
		// <a href="{server_uploaded_image_url}"><img src="{server_uploaded_image_url}" alt="" title="" width="" height"" class="alignzone size-full wp-image-125" /></a>
		var image_url = $('img',html).attr('src');

		//alert(html);
		$('#image2_url').val(image_url);
		tb_remove();
		$('#upload_image2_preview img').attr('src',image_url);

		$('#submit_options_form').trigger('click');
		// $('#uploaded_image2').val('uploaded');
		}

		return false;

	});
});
Silahkan login untuk menjawab!