Laman

Jumat, 04 Oktober 2013

Pemrograman Web Dinamis

                                                           DAFTAR PENYAKIT
koneksi.php
<?php

mysql_connect("localhost","root","");
mysql_select_db("ery");

?>

daftar_data.php
<?php
echo "<h1 align='center'>Daftar Data Penyakit</h1>";
?>
<table border="1" width="550" align="center">
<tr>
 <td height=20 align="center" width=50><b>Kode</b></td>
 <td align="center" width=200><b>Nama Penyakit</b></td>
 <td align='center' width=300><b>Definisi</b></td>
</tr>

<?php
include "koneksi.php";
$qdata = mysql_query("select kode,nama_penyakit,definisi from puskesmas");
while($rdata = mysql_fetch_array($qdata))
{
$kode = $rdata["kode"];
$nama = $rdata["nama_penyakit"];
$definisi = $rdata["definisi"];
echo "<tr>
   <td align='center'>$kode</td>
   <td>$nama</td>
   <td>$definisi</td></tr>";}
?>
</table>







simpan_data.php
<?php

include "koneksi.php";
$kode = $_POST['kode'];
$nama = $_POST['nama_penyakit'];
$definisi= $_POST['definisi'];
$query = "insert into puskesmas (`kode`,`nama_penyakit`,`definisi`)
values ('$kode','$nama','$definisi')";
$hasil = mysql_query($query) or die(mysql_error());
if($hasil)
{
    echo "<h2 align='center'>Pengiriman Data Sukses !</h2>";
}
else {
    echo "<h2 align='center'>Pengiriman Data Gagal !<input type=button value=BACK OnClick=self.history.back();></h2>";
}
?>







edit_penyakit.php
 <?php
include "koneksi.php";
?>
<table border="1" width="550" align="center">
<tr><td height=20 align="center" width=50><b>Kode</b></td>
    <td align="center" width=170><b>Nama Penyakit</b></td>
    <td align='center' width=250><b>Definisi</b></td>
<td align='center' width=80><b>Fungsi</b></td>
</tr>

<?php
    $kirim_edit = (!empty($_GET['kode']) ? $_GET['kode'] : '');
    $edit = (!empty($_GET['edit']) ? $_GET['edit'] : '');
    if($kirim_edit==1)
    {
    $query3 = "update penyakit set kode='$kode_penyakit',nama='$nama_penyakit', definisi='$definisi'where kode='$kodeg'";
    mysql_query($query3);
    }
    $i=0;
    $qdata = mysql_query("select kode ,nama_penyakit,definisi from puskesmas order by kode");
    while($rdata = mysql_fetch_array($qdata))
    {
    $pkode = $rdata["kode"];
    $pnama = $rdata["nama_penyakit"];
    $pdefinisi = $rdata["definisi"];
echo "<tr><td align='center'>$pkode</td><td >$pnama</td>
<td>$pdefinisi</td><td align='center'>
<a href='edit_penyakit.php?kode=$pkode&edit=1'>Edit</a></td></tr>";
$i++;
}
?>
</table>
<br>
<?php
if($edit==1)
{
    $kode = $kirim_edit;
    $qdata2 = mysql_query("select kode,nama_penyakit, definisi from puskesmas where kode='$kode'");
    while($rdata2 = mysql_fetch_array($qdata2))
    {
    $pkode = $rdata["kode"];
    $nama2 = $rdata2["nama_penyakit"];
    $definisi2 = $rdata2["definisi"];
}
echo "<p align='center'>Ubah Data Penyakit <br><br>";
echo "<form method='post' action='edit_data.php'>
<input type='hidden' name='kodeg' value='$kode'>
<input type='hidden' name='kirim_edit' value=1>";
echo "<table border=0 width=500 align='center'>";
echo "<tr><td width=150>Kode Penyakit </td><td><input type='text' name='kode' size=4 value='$kode'></td></tr>
<tr><td>Nama Penyakit </td>
<td><input type='text' name='nama_penyakit' size=40 value='$nama2'></td></tr>
<tr><td valign='middle'>Definisi Penyakit </td>
<td><textarea name='definisi' cols=40 rows=6>$definisi2</textarea></td></tr>
<tr><td colspan=2 align='center'><input type='submit' value='EDIT'></td></tr>";
echo "</table></form></p>";
}
?>
  


form_isi.php
<?php
echo "<h2><p align='center'>Tambah Data Penyakit</h2></p>";
echo "<form method='post' action='simpan_data.php'>";
echo "<table>


<tr>
 <td width=150>Kode Penyakit </td>
 <td><input type='text' name='kode' size=4></td>
</tr>
<tr>
 <td>Nama Penyakit</td>
 <td><input type='text' name='nama_penyakit' size=40></td>
</tr>
<tr>
 <td valign='middle'>Definisi Penyakit </td>
 <td><textarea name='definisi' cols=40 rows=6></textarea></td>
</tr>
<tr>
 <td colspan=2 align='center'><input type='submit' value='OK'></td>
</tr>";
echo "</table></form>";
?> 

hapus_penyakit.php
<?php
 include "koneksi.php";
?>
<table border="1" width="550" align="center">
<tr>
 <td height=20 align="center" width=50><b>Kode</b></td>
 <td align="center" width=170><b>NamaPenyakit</b></td>
 <td align='center' width=250><b>Definisi</b></td>
 <td align='center' width=80><b>Fungsi</b></td>
</tr>

<?php
$hapus = 0;
if(!empty($_GET['hapus'])){
$hapus = $_GET['hapus'];
$kode = $_GET['kode'];
}
if($hapus==1)
{
$query2 = "delete from penyakit where kode='$kode'";
mysql_query($query2);
}
$qdata = mysql_query("select kode,nama_penyakit,definisi from puskesmas order by kode");
$i =0;
while($rdata = mysql_fetch_array($qdata))
{
$pkode = $rdata["kode"];
$pnama = $rdata["nama_penyakit"];
$pdefinisi = $rdata["definisi"];
echo "<tr>
 <td align='center'>$pkode</td>
 <td>$pnama</td>
 <td>$pdefinisi</td>
 <td align='center'>
 <a href='hapus_penyakit.php?kode=$pkode &hapus=1'>Hapus</a></td> </tr>";
$i++;
}
?>
</table>



1 komentar:

  1. Slots & Casinos - MapYRO
    Find the best slot machines in 경주 출장안마 Las Vegas at MapYRO. 광양 출장샵 or pay at casino gaming centers. No matter 경상남도 출장샵 the price, you can also find a 서산 출장안마 variety 대구광역 출장안마 of

    BalasHapus