// Input kategori
if ($module=='isiraker' AND $act=='input'){
$idBulan = $_POST['bulan'];
$idTahun = $_POST['tahun'];
$sqlCek = "select * from isiraker where id_bulan='$idBulan' AND id_tahun='$idTahun'";
if(mysql_num_rows(mysql_query($sqlCek)) <= 1){
foreach($_POST['id_proker'] as $key => $idproker){
$realisasi = $_POST['realisasi'][$key];
for ($i=0;$i<sizeof($idproker);$i++)
{
if ((!empty($idBulan)) && (!empty($idTahun)) && (!empty($realisasi)) && (!empty($idproker)))
{
$sql = "insert into isiraker (id_proker,realisasi,id_bulan,id_tahun)
values ('$idproker','$realisasi','$idBulan','$idTahun')";
mysql_query($sql);
}
}
}
}
<?php
session_start();
if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){
echo "<link href='style.css' rel='stylesheet' type='text/css'>
<center>Untuk mengakses modul, Anda harus login <br>";
echo "<a href=../../index.php><b>LOGIN</b></a></center>";
}
else{
$aksi="bagian/bag_isiraker/aksi_isiraker.php";
switch($_GET[act]){
// Tampil Raker
default:
echo "<h2>Form Pengisian Rencana Kerja</h2>
<form method=POST action='$aksi?module=isiraker&act=input'>
<tr><td>Bulan</td><td> : <select name='bulan'>
<option value=0 selected>- Pilih Bulan -</option>
<option value=1>Januari</option>
<option value=2>Feburari</option>
<option value=3>Maret</option>
<option value=4>April</option>
<option value=5>Mei</option>
<option value=6>Juni</option>
<option value=7>Juli</option>
<option value=8>Agustus</option>
<option value=9>September</option>
<option value=10>Oktober</option>
<option value=11>November</option>
<option value=12>Desember</option>
";
echo "</select></td></tr>
<tr><td>Tahun</td><td> : <select name='tahun'>
<option value=0 selected>- Pilih Tahun -</option>
<option value=2011>2011</option>
<option value=2012>2012</option>
<option value=2013>2013</option>
<option value=2014>2014</option>
<option value=2015>2015</option>
";
echo "</select></td></tr>";
$tampil=mysql_query("SELECT * FROM raker WHERE no='$_SESSION[no]'");
echo " <table>
<tr><th>no</th><th>ID Raker</th><th width=40%>Nama Rencana Kerja</th><th>Bobot</th><th width=20%>Realisasi</th></tr>";
$no=1;
while ($r=mysql_fetch_array($tampil)){
echo "<tr><td>$no</td>
<td><input type=text name='id_proker[]' value='$r[id_raker]' readonly='readonly'></td>
<td>$r[nama_raker]</td>
<td>$r[bobot]</td>
<td><input type='text' name='realisasi[]'>%</td>
</tr>";
$no++;
}
echo "<tr><td colspan=2><input type='submit' name='submit' value=Save Records /></td></tr></table></form>";
echo "<div id=paging>*) Data pada atasan tidak bisa dihapus, tapi bisa di non-aktifkan melalui Edit atasan</div><br>";
break;
}
}
?>
<?php
session_start();
if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){
echo "<link href='style.css' rel='stylesheet' type='text/css'>
<center>Untuk mengakses modul, Anda harus login <br>";
echo "<a href=../../index.php><b>LOGIN</b></a></center>";
}
else{
$aksi="bagian/bag_isiraker/aksi_isiraker.php";
switch($_GET[act]){
// Tampil Raker
default:
echo "<h2>Form Pengisian Rencana Kerja</h2>
<form method=POST action='$aksi?module=isiraker&act=input'>
<tr><td>Bulan</td><td> : <select name='bulan'>
<option value=0 selected>- Pilih Bulan -</option>
<option value=1>Januari</option>
<option value=2>Feburari</option>
<option value=3>Maret</option>
<option value=4>April</option>
<option value=5>Mei</option>
<option value=6>Juni</option>
<option value=7>Juli</option>
<option value=8>Agustus</option>
<option value=9>September</option>
<option value=10>Oktober</option>
<option value=11>November</option>
<option value=12>Desember</option>
";
echo "</select></td></tr>
<tr><td>Tahun</td><td> : <select name='tahun'>
<option value=0 selected>- Pilih Tahun -</option>
<option value=2011>2011</option>
<option value=2012>2012</option>
<option value=2013>2013</option>
<option value=2014>2014</option>
<option value=2015>2015</option>
";
echo "</select></td></tr>";
$tampil=mysql_query("SELECT * FROM raker WHERE no='$_SESSION[no]'");
echo " <table>
<tr><th>no</th><th>ID Raker</th><th width=40%>Nama Rencana Kerja</th><th>Bobot</th><th width=20%>Realisasi</th></tr>";
$no=1;
while ($r=mysql_fetch_array($tampil)){
echo "<tr><td>$no</td>
<td><input type=text name='id_proker[]' value='$r[id_raker]' readonly='readonly'></td>
<td>$r[nama_raker]</td>
<td>$r[bobot]</td>
<td><input type='text' name='realisasi[]'>%</td>
</tr>";
$no++;
}
echo "<tr><td colspan=2><input type='submit' name='submit' value=Save Records /></td>
<td></td><td>Total</td><td><input type='text' name='total' id='total'/></td>
</tr></table></form>";
echo "<div id=paging>*) Data pada atasan tidak bisa dihapus, tapi bisa di non-aktifkan melalui Edit atasan</div><br>";
break;
}
}
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('input[name^="realisasi"]').keyup(function(){
var total = 0;
$('input[name^="realisasi"]').each(function(){
total += parseFloat($(this).val());
});
$("#total").val(total);
});
});
</script>