<?php
<?
mysql_connect("","","");
mysql_select_db("handphone");
$type=$_GET['type'];
$tampil=mysql_query("select * from nokia where type='$type'");
while ($data=mysql_fetch_array($tampil))
{$no++;
?>
<!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>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<body>
<table width="50%" border="1" align="center">
<tr>
<td colspan="3"><div align="center"><strong>KERANJANG</strong></div></td>
</tr>
<tr>
<td width="35%"><strong>TYPE</strong></td>
<td colspan="2"><strong>
<label>
<input name="type" type="text" class="style1" id="type" value="<? echo $data[0]; ?>" />
</label>
</strong></td>
</tr>
<tr>
<td><strong>HARGA</strong></td>
<td colspan="2"><input name="harga" type="text" class="style1" id="harga" value="<? echo $harga[1]; ?>" /></td>
</tr>
<tr>
<td><strong>JUMLAH</strong></td>
<td colspan="2"><input name="jumlah" type="text" class="style1" id="jumlah" value="<? echo $jumlah; ?>" maxlength="3" /></td>
<?
$jumlah=$_POST['jumlah'];
$total=$data[1]*$jumlah['jumlah'];
?>
</tr>
<tr>
<td><strong>TOTAL</strong></td>
<td colspan="2"><input name="total" type="text" class="style1" id="total" value="<? echo $total; ?>" /></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td height="47"><div align="center"><a href="depan.php"><img src="BUTTON/AddtoCart.gif" width="92" height="25" border="0" /></a></div></td>
<td width="31%"><div align="center"><img src="Batal.jpg" width="89" height="21" /></div></td>
<td width="34%"><label>
</label>
<img src="submit.jpg" width="89" height="21" /></td>
</tr>
</table>
</body>
</html>
<? } ?>
?>
<tr>
<td>Keahlian Plus</td>
<td>:</td>
<td><input type="checkbox" name="ahli[]" value="Bahasa-Inggris"/>Bahasa Inggris</td>
<td><label><input type="checkbox" name="ahli[]" value="Komputer"/>
Komputer</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="checkbox" name="ahli[]" value="Bahasa-Jepang"/>
Bahasa Jepang</td>
<td><input type="checkbox" name="ahli1" value="" onclick="muncul1()"/>
<input type="text" name="addAhli1" value="" id="addAhli1" disabled/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="checkbox" name="ahli[]" value="Bahasa-Jerman"/>
Bahasa Jerman</td>
<td><input type="checkbox" name="ahli2" value="" onclick="muncul2()"/>
<input type="text" name="addAhli2" value="" id="addAhli2" disabled/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="checkbox" name="ahli[]" value="Bahasa-Rusia"/>
Bahasa Rusia</td>
<td><input type="checkbox" name="ahli3" value="" onclick="muncul3()"/>
<input type="text" name="addAhli3" value="" id="addAhli3" disabled/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="checkbox" name="ahli[]" value="Bahasa-Mandarin"/>
Bahasa Mandarin</td>
<td><input type="checkbox" name="ahli4" value="" onclick="muncul4()"/>
<input type="text" name="addAhli4" value="" id="addAhli4" disabled/></td>
</tr>
Nah.., disana terdapat beberapa checkbox yang harus di check dulu maka textfield disampingnya akan enable (jika mempunyai keahlian lain selain yang ada dipilihan).$ahli_array = $_POST['ahli'];
foreach ($ahli_array as $satu_ahli) {
$source .= $satu_ahli.", ";
}$ahli = substr($source, 0, -2);
$query = "INSERT INTO tbl_pegawai (keahlian_plus) VALUES ('$ahli')";
$result = mysql_query($query);
Mohon penjelasan dan solusinya.if((!empty($_POST['nmbu'])) and (!empty($_POST['mk']))){
$nmbu_ = $_POST['nmbu'];
$hitnmbu = count($nmbu);
$mk_ = $_POST['mk'];
$hitmk = count($mk_);
}
if((empty($_POST['nmbu'])) and (empty($_POST['mk']))){
echo "<script>alert('Maaf, mohon lengkapi input yang tersedia !');history.go(-1);</script>";
}else{
$lolos = true;
}
if($lolos){
for($x=0;$x<$hitnmbu;$x++){
if(!empty($nmbu_[$x])){
mysql_query("insert into krs1 (NIMHS,NMMHS,kodekuliah,BU,KDSEMES,tahun) values ('$NIMHS','$NMMHS','$mk_[$x]','$nmbu_[$x]','$semester','$tahun')");
}
}
}
yang saya pertanyakan, kenapa pesan alert'y tidak tampiL, jika megkosongkan mk dan nmbu <?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>
[code]
peyimpanan:
[code]
?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{
include "../../config/koneksi.php";
include "../../config/fungsi_seo.php";
$module=$_GET[module];
$act =$_GET[act];
// 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);
}
}
}
}
header('location:../../Utama.php?module='.$module);
if($sql) echo "Input data sukses<br>";
else echo "Input data gagal<br>";
}
// Update kategori
elseif ($module=='atasan' AND $act=='update'){
mysql_query("UPDATE atasan SET kode_atasan='$_POST[kode_atasan]',nama='$_POST[nama]'
WHERE kode_atasan = '$_POST[id]'");
header('location:../../Utama.php?module='.$module);
}
}
?>