CREATE TABLE `riwayat_takah` (
`nip` varchar(20) NOT NULL,
`fid_takah` varchar(5) NOT NULL,
`status` enum('ADA','TIDAK ADA') NOT NULL,
`note` varchar(255) NOT NULL,
KEY `id_takah` (`fid_takah`),
KEY `nip` (`nip`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `ref_takah` (
`id_takah` varchar(5) NOT NULL,
`nama_takah` varchar(255) NOT NULL,
PRIMARY KEY (`id_takah`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
$no=1;
while ($r=mysql_fetch_array($sqltakah)){
if ($r[nip]!=null) {
echo "<tr><td align=center><font color='#32CD32'>$no</font></td>";
echo "<td><font color='#32CD32'>$r[nama_takah]</font></td>";
echo "<td><center><font color='#32CD32'>ADA</font></center></td>";
echo "<td align='center'>
<input type='checkbox' name='cek[]' id=id$no value='$r[id_takah]' checked >$r[id_takah]</td>";
echo "<td><span id='other1' style='display:inline'>
<input type='text' name='otherjob'/>
</span></td>";
} else {
echo "<tr><td align=center><font color='#DC143C'>$no</font></td>";
echo "<td><font color='#DC143C'>$r[nama_takah]</font></td>";
echo "<td><center><font color='#DC143C'>TIDAK ADA</font></center></td>";
echo "<td align='center'>
<input type='checkbox' name='cek[]' id=id$no value='1'
onCheck='centang(this.value);' >$r[id_takah]</td>";
echo "<td><span id='other' style='display:none'>
<input type='text' name='otherjob'/>
</span></td>";
}
$no++;
}
$no=1;
while ($r=mysql_fetch_array($sqltakah)){
if ($r[nip]!=null) {
echo "<tr><td align=center><font color='#32CD32'>$no</font></td>";
echo "<td><font color='#32CD32'>$r[nama_takah]</font></td>";
echo "<td><center><font color='#32CD32'>ADA</font></center></td>";
echo "<td align='center'>
<input type='checkbox' name='cek[$no]' id=id$no value='$r[id_takah]' checked >$r[id_takah]</td>";
echo "<td><span id='other1' style='display:inline'>
<input type='text' name='otherjob[$no]'/>
</span></td>";
} else {
echo "<tr><td align=center><font color='#DC143C'>$no</font></td>";
echo "<td><font color='#DC143C'>$r[nama_takah]</font></td>";
echo "<td><center><font color='#DC143C'>TIDAK ADA</font></center></td>";
echo "<td align='center'>
<input type='checkbox' name='cek[$no]' id=id$no value='-1'
onCheck='centang(this.value);' >$r[id_takah]</td>";
echo "<td><span id='other' style='display:none'>
<input type='text' name='otherjob[$no]'/>
</span></td>";
}
$no++;
}
kemudian menyimpannya sepertiif($_POST){
foreach($_POST['cek'] as $no => $nilai){
if($nilai == -1 ){ // berarti TIDAK ADA yang dicentang
//lakukan hal lain
}else{
$otherjob = $_POST['otherjob'][$no];
//simpan data
}
}
}