Ini adalah code untuk tampilan diatas (tampil_data.php) :
<title>Menampilkan data Database Oracle dengan PHP</title>
<?php
include "konek.php"; // untuk memanggil koneksi
$PeritahSql="select * from EMP";
$Query = oci_parse($koneksi,$PeritahSql);
oci_execute($Query);
echo "<b>";
echo "<center>DAFTAR KARYAWAN BARISAN SAKIT HATI</center>";
echo "<center>CILEGON - BANTEN</center>";
echo "</b>";
echo "<table width='80%' border='1' align='center'>";
echo "<td width='100%' colspan='6' align='right'><a href='frm_input.php'>TAMBAH DATA</a></td>";
echo "<tr align='center'><td>EMP. NO</td><td>EMP. NAME</td><td>JOB</td><td>HIRE DATE</td><td colspan='2'>ACTION</td></tr>";
while (oci_fetch_array($Query)){
echo "<tr>
<td width='10%'>".ociresult($Query,"EMPNO")."</td>
<td width='30%'>".ociresult($Query,"ENAME")."</td>
<td width='30%'>".ociresult($Query,"JOB")."</td>
<td width='10%'>".ociresult($Query,"HIREDATE")."</td>
<td width='5%' align='center'><a href='frm_edit.php?empno=".ociresult($Query,"EMPNO")."'>".EDIT."</a></td>
<td width='5%' align='center'><a href='proses_deldata.php?empno=".ociresult($Query,"EMPNO")."'>".HAPUS."</a></td>
</tr>";
}
//Menghitung jumlah data
$PeritahSqlJumlah="select COUNT (EMPNO) as JUMLAH from EMP";
$QueryJumlah = oci_parse($koneksi,$PeritahSqlJumlah);
oci_execute($QueryJumlah);
oci_fetch_array($QueryJumlah);
echo "<td width='100%' colspan='6'>Jumlah Data : ".ociresult($QueryJumlah,"JUMLAH")."</td>";
echo "</table>";
oci_close($koneksi); // untuk menutup koneksi
?>
<?php
include "konek.php"; // untuk memanggil koneksi
$PeritahSql="select * from EMP";
$Query = oci_parse($koneksi,$PeritahSql);
oci_execute($Query);
echo "<b>";
echo "<center>DAFTAR KARYAWAN BARISAN SAKIT HATI</center>";
echo "<center>CILEGON - BANTEN</center>";
echo "</b>";
echo "<table width='80%' border='1' align='center'>";
echo "<td width='100%' colspan='6' align='right'><a href='frm_input.php'>TAMBAH DATA</a></td>";
echo "<tr align='center'><td>EMP. NO</td><td>EMP. NAME</td><td>JOB</td><td>HIRE DATE</td><td colspan='2'>ACTION</td></tr>";
while (oci_fetch_array($Query)){
echo "<tr>
<td width='10%'>".ociresult($Query,"EMPNO")."</td>
<td width='30%'>".ociresult($Query,"ENAME")."</td>
<td width='30%'>".ociresult($Query,"JOB")."</td>
<td width='10%'>".ociresult($Query,"HIREDATE")."</td>
<td width='5%' align='center'><a href='frm_edit.php?empno=".ociresult($Query,"EMPNO")."'>".EDIT."</a></td>
<td width='5%' align='center'><a href='proses_deldata.php?empno=".ociresult($Query,"EMPNO")."'>".HAPUS."</a></td>
</tr>";
}
//Menghitung jumlah data
$PeritahSqlJumlah="select COUNT (EMPNO) as JUMLAH from EMP";
$QueryJumlah = oci_parse($koneksi,$PeritahSqlJumlah);
oci_execute($QueryJumlah);
oci_fetch_array($QueryJumlah);
echo "<td width='100%' colspan='6'>Jumlah Data : ".ociresult($QueryJumlah,"JUMLAH")."</td>";
echo "</table>";
oci_close($koneksi); // untuk menutup koneksi
?>
Tampilan pada saat link EDIT di klik
Script untuk membuat Form Edit (frm_edit.php)
<!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=utf-8" />
<title>.: EDIT DATA :.</title>
<!-- Memanggil file layout.css -->
<script language="javascript" src="calendar/calendar.js"></script>
</head>
<body>
<?php
require_once('calendar/classes/tc_calendar.php');
include "konek.php"; // untuk memanggil koneksi
$empno=$_GET['empno'];
$PeritahSql="SELECT EMP.*,DEPT.DNAME FROM EMP,DEPT where EMP.DEPTNO=DEPT.DEPTNO AND EMPNO='$empno'";
//untuk mempercepat proses query field harus di sebutkan
//dengan sintak diatas akan memanggil semua field yang ada di table EMP
$Query = oci_parse($koneksi,$PeritahSql);
oci_execute($Query);
oci_fetch_array($Query);
?>
<form id="form1" name="form1" method="post" action="proses_edtdata.php">
<table width="100%" border="0">
<tr>
<td> </td>
<td width="17%"> </td>
<td width="2%"> </td>
<td width="36%"> </td>
<td> </td>
</tr>
<tr>
<td width="17%"> </td>
<td colspan="3"><strong>FORM EDIT DATA</strong></td>
<td width="45%"> </td>
</tr>
<tr>
<td> </td>
<td>EMP ID</td>
<td>
</td>
<td><label>
<input name="empno" type="text" id="empno" value="<?php echo ociresult($Query,"EMPNO") ?>" size="20" readonly="readonly" />
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>EMP NAME</td>
<td> </td>
<td><input name="empname" type="text" id="empname" value="<?php echo ociresult($Query,"ENAME") ?>" size="60" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>JOB</td>
<td> </td>
<td><input name="job" type="text" id="job" value="<?php echo ociresult($Query,"JOB") ?>" size="60" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>HIRE DATE</td>
<td> </td>
<td><?php
$date1_default=ociresult($Query,"HIREDATE");
$myCalendar = new tc_calendar("date", true);
$myCalendar->setIcon("calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d', strtotime($date1_default))
, date('m', strtotime($date1_default))
, date('Y', strtotime($date1_default)));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(1960, 2015);
$myCalendar->writeScript();
?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>SALARY</td>
<td> </td>
<td><input type="text" name="salary" id="salary" value="<?php echo ociresult($Query,"SAL") ?>" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>DEPT</td>
<td> </td>
<td><label>
<select name="dept" id="dept">
<?php
echo "<option value=".ociresult($Query,"DEPTNO").">".ociresult($Query,"DNAME")."</option>";
$PeritahSql1="SELECT * FROM DEPT";
$Query1 = oci_parse($koneksi,$PeritahSql1);
oci_execute($Query1);
while (oci_fetch_array($Query1)){
echo "<option value=".ociresult($Query1,"DEPTNO").">".ociresult($Query1,"DNAME")."</option>";
}
?>
</select>
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><label>
<input type="submit" name="simpan" id="simpan" value="Save" />
</label></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.: EDIT DATA :.</title>
<!-- Memanggil file layout.css -->
<script language="javascript" src="calendar/calendar.js"></script>
</head>
<body>
<?php
require_once('calendar/classes/tc_calendar.php');
include "konek.php"; // untuk memanggil koneksi
$empno=$_GET['empno'];
$PeritahSql="SELECT EMP.*,DEPT.DNAME FROM EMP,DEPT where EMP.DEPTNO=DEPT.DEPTNO AND EMPNO='$empno'";
//untuk mempercepat proses query field harus di sebutkan
//dengan sintak diatas akan memanggil semua field yang ada di table EMP
$Query = oci_parse($koneksi,$PeritahSql);
oci_execute($Query);
oci_fetch_array($Query);
?>
<form id="form1" name="form1" method="post" action="proses_edtdata.php">
<table width="100%" border="0">
<tr>
<td> </td>
<td width="17%"> </td>
<td width="2%"> </td>
<td width="36%"> </td>
<td> </td>
</tr>
<tr>
<td width="17%"> </td>
<td colspan="3"><strong>FORM EDIT DATA</strong></td>
<td width="45%"> </td>
</tr>
<tr>
<td> </td>
<td>EMP ID</td>
<td>
</td>
<td><label>
<input name="empno" type="text" id="empno" value="<?php echo ociresult($Query,"EMPNO") ?>" size="20" readonly="readonly" />
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>EMP NAME</td>
<td> </td>
<td><input name="empname" type="text" id="empname" value="<?php echo ociresult($Query,"ENAME") ?>" size="60" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>JOB</td>
<td> </td>
<td><input name="job" type="text" id="job" value="<?php echo ociresult($Query,"JOB") ?>" size="60" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>HIRE DATE</td>
<td> </td>
<td><?php
$date1_default=ociresult($Query,"HIREDATE");
$myCalendar = new tc_calendar("date", true);
$myCalendar->setIcon("calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d', strtotime($date1_default))
, date('m', strtotime($date1_default))
, date('Y', strtotime($date1_default)));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(1960, 2015);
$myCalendar->writeScript();
?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>SALARY</td>
<td> </td>
<td><input type="text" name="salary" id="salary" value="<?php echo ociresult($Query,"SAL") ?>" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>DEPT</td>
<td> </td>
<td><label>
<select name="dept" id="dept">
<?php
echo "<option value=".ociresult($Query,"DEPTNO").">".ociresult($Query,"DNAME")."</option>";
$PeritahSql1="SELECT * FROM DEPT";
$Query1 = oci_parse($koneksi,$PeritahSql1);
oci_execute($Query1);
while (oci_fetch_array($Query1)){
echo "<option value=".ociresult($Query1,"DEPTNO").">".ociresult($Query1,"DNAME")."</option>";
}
?>
</select>
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><label>
<input type="submit" name="simpan" id="simpan" value="Save" />
</label></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Download script lengkap (konek.php, tampil_data.php, frm_input.php, frm_edit.php, proses_edtdata.php, proses_indata.php, proses_deldata.php) disini.
Mohon di koreksi jika ada yang salah dan Semoga bermanfaat.... :)
Cakep . . . . . .
BalasHapusSemoga ilmunya semakin bermanfaat.. Terimakasih
BalasHapusmantap.. Bro..
BalasHapuskunjungi balik yo
zagalarupa.blogspot.com
dtabase nya mna bro.,.?
BalasHapusDatabasenya bawaan oracle nya mas bro...
BalasHapusGan mau tanya, kl menampilkan nilai ke radio button dari database oracle untuk FormEdit gimana caranya ya?, supaya pada saat membuka FormEdit radio buttonnya ada nilainya (misalnya di radio button LELAKI ada nilainya tp di radio button PEREMPUAN ngk ada nilainya), terima kasih
BalasHapusMANTAV
BalasHapusFILENYA TAPI KOK UDAH DIHAPUS. UPLOAD LAGI BOS
BalasHapusFILENYA TAPI KOK UDAH DIHAPUS. UPLOAD LAGI BOS
BalasHapusMANTAV
BalasHapusfile dong gan perlu banget nih
BalasHapusfilenya bro... keep update...
BalasHapus