twitter
googleplus
facebook

TUGAS PEMROGRAMAN WEB DINAMIS 2

EDIT.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>
<?if($kirim_edit==1)
{
$query3 = “update data_penyakit set kode=’$kode_penyakit’,
nama=’$nama_penyakit’, definisi=’$definisi’
where kode=’$kodeg’”;
mysql_query($query3);
}
$i=0;
$qdata = mysql_query(“select kode,nama,definisi from data_penyakit order by kode”);
while($rdata = mysql_fetch_array($qdata))
{
$pkode = $rdata["kode"];
$pnama = $rdata["nama"];
$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>
<?if($edit==1)
{
$qdata2 = mysql_query(“select nama, definisi from penyakit where kode=’$kode’”);
while($rdata2 = mysql_fetch_array($qdata2))
{
$nama2 = $rdata2["nama"];
$definisi2 = $rdata2["definisi"];
}
echo “<p align=’center’>Ubah Data Penyakit <br><br>”;
echo “<form method=’post’ action=’edit_penyakit.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_penyakit’ 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>”;
}
?>

Image

HAPUS DATA

<? 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>
<?
if($hapus==1)
{
$query2 = “delete from data_penyakit where kode=’$kode’”;
mysql_query($query2);
}
$qdata= mysql_query(“select kode,nama,definisi from data_penyakitorder by kode”);
while($rdata= mysql_fetch_array($qdata))
{
$pkode= $rdata["kode"];
$pnama= $rdata["nama"];
$pdefinisi= $rdata["definisi"];
echo “<tr><td align=’center’>kode</td><td >nama</td>
<td>definisi</td><td align=’center’>
<a href=’hapus_penyakit.php?kode=$pkode&hapus=1′>Hapus</a></td></tr>”;
$i++;
}?>
</table>
Image


TAMPILAN DATA

<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,definisi from data_penyakit”);
while($rdata = mysql_fetch_array($qdata))
{
$kode = $rdata["kode"];
$nama = $rdata["nama"];
$definisi = $rdata["definisi"];
echo “<tr><td align=’center’>$kode</td>
<td>$nama</td>
<td>$definisi</td></tr>”;
}?>
</table>
Image

SIMPAN DATA

<?php
include “koneksi.php”;
$kode = $_POST['kode_penyakit'];
$nama = $_POST['nama_penyakit'];
$definisi = $_POST['definisi'];
$query = “insert into data_penyakit (kode,nama,definisi)
values (‘$kode_penyakit’,'$nama_penyakit’,'$definisi’)”;
$hasil = mysql_query($query);
if($hasil)
{
echo “<h3 align=’center’>Pengiriman Data Sukses !</h3>”;
} else {
echo “<h3 align=’center’>Pengiriman Data Gagal !
<input type=button value=BACK OnClick=self.history.back();></h3>”;
}
?>

ISI DATA

<?php
echo “<p align=’center’>Tambah Data Penyakit</p>”;
echo “<form method=’post’ action=’simpandata.php’>”;
echo “<table><tr><td width=150>Kode Penyakit </td>
<td><input type=’text’ name=’kode_penyakit’ 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>”;?>

Image
Koneksi.php

<?php
mysql_connect(“localhost”,”root”,”");
mysql_select_db(“tugasPWD”);
?>








  • Title : TUGAS PEMROGRAMAN WEB DINAMIS 2
  • Labels :
  • Author :
  • Rating: 100% based on 10 ratings. 5 user reviews.
  • 0 komentar:

    Posting Komentar