dear para Master,
mohon dibantu
saya ada kendala penyimpanan data dengan checkbox, dimana saya tidak dapat mengambil data dari list tabel yang saya tampil
yaitu, makul,sks,hari,tayang,pengajar,id_pengajar.
berikut coding tampil
<h4> Kehadiran Mahasiswa/i </h4>
<?php
include "koneksi/koneksi.php";
// ubah ke dalam variabel
$nis = $_GET['nis'];
$nama = $_GET['nama'];
$nama1 = $_GET['nama1'];
//$namas = $_GET['namas'];
// ambil data berdasarkan id siswa yang dimasukkan
//$sql = mysql_query("select * from siswa where nis='$nis'");
$sql = mysql_fetch_array(mysql_query("select * from siswa where nis ='$nis'"));
$id_jr=$sql['id_jr'];
$id_prodis=$sql['id_prodis'];
$sql1 = mysql_fetch_array(mysql_query("select * from jurusan where id_jurus ='$id_jr'"));
$sql2 = mysql_fetch_array(mysql_query("select * from prodi where id_prodi ='$id_prodis'"));
$smith=$sql2['id_prodi'];
//$hasil = mysql_query("SELECT siswa.nis, siswa.namas,siswa.alamat, siswa.hp, jurusan.nama, prodi.nama1 FROM siswa,
// jurusan, prodi WHERE siswa.id_prodis=prodi.id_prodi and siswa.id_jr=jurusan.id_jurus limit $offset,$limit");
// hitung jumlah
?>
<form method=post action=?menu=create_kuliah>
<table border=1>
<tr>
<td> NIS </td>
<td> : </td>
<td><?php echo "$sql[nis]"; ?><input type=hidden name=nis maxlength=20 value="<?php echo "$sql[nis]"; ?>"> </td>
</tr>
<tr>
<td> Nama Siswa </td>
<td> : </td>
<td><?php echo "$sql[namas]"; ?><input type=hidden name=namas maxlength=20 value="<?php echo "$sql[namas]"; ?>"> </td>
</tr>
<tr>
<td> Jurusan </td>
<td> : </td>
<td><?php echo "$sql1[nama]"; ?><input type=hidden name=jurus maxlength=20 value="<?php echo "$sql1[nama]"; ?>"> </td> </tr>
<tr>
<td> Prodi </td>
<td> : </td>
<td><?php echo "$sql2[nama1]"; ?><input type=hidden name=pros maxlength=20 value="<?php echo "$sql2[nama1]"; ?>"> </td> </tr>
</tr>
<tr>
<td colspan=3> <input type=submit value=Simpan> <input type=submit value=Batal onClick=history.back()> </td>
</tr>
</table>
<?php
// panggil semua data dari tabel makul diurutkan berdasarkan id makul, dibatasi dengan limit = 15
//$hasil1= mysql_query("select * from makul1 where hari='$fri'");
include "koneksi/koneksi.php";
$hasil = mysql_query("select * from makul1, pengajar where id_prodi='$smith' and makul1.nip=pengajar.id_pengajar");
$k = 1;
$k = 1 + $offset;
echo"
<div align=left>
<table border=1 width=100%>
<tr>
<th> No. </th>
<th> id makul </th>
<th> makul </th>
<th> SKS </th>
<th> Hari </th>
<th> Jam Tayang </th>
<th> Pengajar </th>
<th width=70> Ambil Mata Kuliah </th>
</tr>
";
while ($data = mysql_fetch_array($hasil)) {
echo"
<tr>
<td width=10 align=center> $k </td>
<td> $data[id_makul] </td>
<td> $data[makul] </td>
<td> $data[sks] </td>
<td> $data[hari] </td>
<td> $data[tayang] </td>
<td> $data[pengajar] </td>
<td align='center'><input type='checkbox' name='item[]' id_makul='item[]' value='$data[id_makul]'>
<td><input type='checkbox' value='".$data['id_makul']."' name='mk".$no."' /> ".$data['namaMK']."<br />
<td> <a href=index.php?menu=edit_makul&id_makul=$data[id_makul] title='Edit makul'> Edit </a> | <a href=index.php?menu=hapus_makul&id_makul=$data[id_makul] title='Hapus makul'> Hapus </a> </td
</tr>
";
$k++;
}
//untuk tutup tabel
//echo "</table>";
//echo "<div class=paging>";
//TES
//echo "</div";
//echo "</font>";
?>
kemudian saya submit dgn code
<?php
// uraikan parameter post ke dalam bentuk variabel
include "koneksi/koneksi.php";
$jumlah = count($_POST["item"]);
for($i=0; $i < $jumlah; $i++)
{
$nis = $_POST['nis'];
$namas = $_POST['namas'];
$jurus = $_POST['jurus'];
$pros = $_POST['pros'];
$id_makul = $_POST['id_makul'];
$makul = $_POST['makul'.$i];
$sql = mysql_fetch_array(mysql_query("select * from siswa where nis ='$nis'"));
$id_jr=$sql['id_jr'];
$id_prodis=$sql['id_prodis'];
$sql1 = mysql_fetch_array(mysql_query("select * from jurusan where id_jurus ='$id_jr'"));
$sql2 = mysql_fetch_array(mysql_query("select * from prodi where id_prodi ='$id_prodis'"));
$smith=$sql2['id_prodi'];
$hasil = mysql_query("select * from makul1, pengajar where id_prodi='$smith' and makul1.nip=pengajar.id_pengajar ");
while ($data = mysql_fetch_array($hasil)) {
//$makul = $data[makul];
$sks = $_POST['sks'];
$hari = $_POST['hari'];
$tayang = $_POST['tayang'];
$id_pengajar = $_POST['id_pengajar'];
$pengajar = $_POST['pengajar'];
$id_makul=$_POST["item"][$i];
//$makul=$_POST["item1"][$i];
}
// $q=pg_query("insert into kontra values ('$nim','aktif')");
$q = mysql_query("insert into kontra(nis,nama,jurusan,prodi,id_makul,makul,sks,hari,tayang,id_pengajar,pengajar,status) values('$nis',
'$namas','$jurus','$pros','$id_makul','$makul','$sks','$hari','$tayang','$id_pengajar','$pengajar','kontrak')");
//$masuk = mysql_query("insert into kontra(nis,namas,alamat,hp,id_jr,id_prodis,smi) values('$nis','$nama','$alamat','$hp','$jurusan','$jag1','$smi')");
}
if ($q){
echo"Data Berhasil disimpan";
}
else
{
echo"Data Gagal Disimpan";
}
?>
terima kasih atas bantuannya,
BestRegards,