0% found this document useful (0 votes)
21 views8 pages

Simpan Dengan Jabatan - PHP

This PHP code manages job positions (jabatan) in a database. It allows the user to view existing positions, add new positions, update positions, and delete positions. When the page loads, it displays all existing positions from the database. It also includes form fields to add or edit a position, with logic to handle submitting the form data to the database.

Uploaded by

Bambang Widodo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views8 pages

Simpan Dengan Jabatan - PHP

This PHP code manages job positions (jabatan) in a database. It allows the user to view existing positions, add new positions, update positions, and delete positions. When the page loads, it displays all existing positions from the database. It also includes form fields to add or edit a position, with logic to handle submitting the form data to the database.

Uploaded by

Bambang Widodo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Simpan dengan Jabatan.

php
<?
include_once "connect.php";
$SQL_1="SELECT
jbtn.IDJabatan,
jbtn.ID_Satker,
jbtn.NamaJabatan,
jbtn.TunjanganJabatan,
sat.NamaSatker
FROM
jabatan jbtn
left join
satker sat
on
jbtn.ID_Satker=sat.ID_Satker";
if(isset($_GET['status'])){
if($_GET['status']=="ubah"){
$SQL_2="SELECT
jbtn.IDJabatan,
jbtn.ID_Satker,
jbtn.NamaJabatan,
jbtn.TunjanganJabatan,
sat.NamaSatker
FROM
jabatan jbtn
left join
satker sat
on
jbtn.ID_Satker=sat.ID_Satker
where jbtn.IDJabatan=".$_GET['id'];
$result_2=mysql_query($SQL_2) or die("Error Filter");
$value_form=mysql_fetch_object($result_2);
if(isset($_POST['btnSimpan'])){
$sqlUpdate="Update jabatan Set ".
"ID_Satker='".$_POST['ID_Satker']."',".
"NamaJabatan='".$_POST['NamaJabatan']."',".
"TunjanganJabatan=".$_POST['TunjanganJabatan'].
" where IDJabatan=".$_GET['id'];
$resultUpdate=mysql_query($sqlUpdate)
or die("Update Data gagal.");
header("Location: jabatan.php");
}
}
if($_GET['status']=="new"){
if(isset($_POST['btnSimpan'])){
$SQL_3="INSERT INTO
jabatan(ID_Satker,NamaJabatan,TunjanganJabatan)". "
VALUES(".

"'".$_POST['ID_Satker']."',".
"'".$_POST['NamaJabatan']."',".
$_POST['TunjanganJabatan'].
")";
if($_POST['NamaJabatan']!=NULL){
$result_3=mysql_query($SQL_3)or die("Data baru Gagal Di Simpan");
header("Location: jabatan.php");
}
}

}
if($_GET['status']=="hapus"){
$sqlDelete="Delete from jabatan where IDJabatan='".$_GET['id']."'";
$result_delete=mysql_query($sqlDelete)or die("Gagal Di Hapus");
header("Location: jabatan.php");
}

}
?>
<html>
<head>
<title>Jabatan</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="">
<h1 align="center">Jabatan</h1>
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><table width="99%" border="0" align="center" cellpadding="0"
cellspacing="2" style="font-family:arial;font-size:12px;color:black;font-weight:lighter">
<tr>
<td width="31%" height="25">Satuan Kerja</td>
<td width="69%">
<select name="ID_Satker" id="ID_Satker" style="font-family:arial;fontsize:12px;color:black;font-weight:lighter;width:100">
<?
$satkerIDSelected=@$_GET['idSat'];
$SQL_satker="Select ID_Satker,NamaSatker from satker";
$resultSatker=mysql_query($SQL_satker);
while($rowSatker=mysql_fetch_object($resultSatker)){
?>
<option value="<? print $rowSatker->ID_Satker?>" <?
if($satkerIDSelected==$rowSatker->ID_Satker){?>selected <? } ?>>
<? print $rowSatker->NamaSatker;?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Nama Jabatan</td>
<td><input name="NamaJabatan" type="text" id="NamaJabatan" style="fontfamily:arial;font-size:12px;color:black;font-weight:lighter;width:250" value="<? print
@$value_form->NamaJabatan;?>"></td>
</tr>

<tr>
<td>Tunjangan Jabatan</td>
<td>
<input name="TunjanganJabatan" type="text" id="TunjanganJabatan" style="fontfamily:arial;font-size:12px;color:black;font-weight:lighter;width:100"
value="<?print @$value_form->TunjanganJabatan;?>"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td>&nbsp;</td>
<td><input name="btnSimpan" type="submit" id="btnSimpan" value="Simpan">
<input type="button" value="Tambah" name="btnTambah"
onClick="javaScript:location.href='jabatan.php?status=new'"></td>
</tr>
</table></td>
</tr>
</table>
</form>
<table width="800" id="table1" style="font-family:arial;font-size:12px;color:black;fontweight:lighter">
<tr bgcolor="#CCCCCC">
<td width="224" height="22">Nama Satuan Kerja</td>
<td width="213">Nama Jabatan</td>
<td width="236">Tunjangan</td>
<td width="107">&nbsp;</td>
</tr>
<?
$result_1=mysql_query($SQL_1);
while($row=mysql_fetch_object($result_1)){
?>
<tr bgcolor="#00CCFF">
<td><? print $row->NamaSatker?></td>
<td><? print $row->NamaJabatan?></td>
<td><? print $row->TunjanganJabatan?></td>
<td><input name="btnHapus" type="submit" id="btnHapus" style="font-family:arial;fontsize:12px;color:black;font-weight:lighter;width:50" onclick="javaScript:location.href='jabatan.php?
status=hapus&id=<? print $row->IDJabatan?>'" value="Hapus">
<input name="btnUbah" type="submit" id="btnUbah" style="font-family:arial;fontsize:12px;color:black;font-weight:lighter;width:50" onclick="javaScript:location.href='jabatan.php?
status=ubah&id=<? print $row->IDJabatan?>&idSat=<? print $row->ID_Satker;?>'"
value="Ubah"></td>
</tr>
<? } ?>
</table>

<br>
<a href="index.php" style="font-family:arial;font-size:12px;textdecoration:none;color:#000000">Menu
Utama</a></html>
<? include "disconnect.php"; ?>

You might also like