Okey, pertama anda buat file yang bernama form-delete.php, kemudian isi dengan script php di bawah ini...
<table width="30%" class="akutabel">
<tr>
<td align="center" bgcolor="#FF0000">NAMA</td>
<td align="center" bgcolor="#FF0000">NIM</td>
<td align="center" bgcolor="#FF0000">HAPUS</td>
</tr>
<?php
include("uji.php");
mysql_select_db("amburadul");
$sql="select * from biodata order by no";
$hasil=mysql_query($sql);
while($data=mysql_fetch_row($hasil)){
echo"
<tr>
<td>$data[1]</td>
<td>$data[2]</td>
<td><a href="proses-hapus.php?no=$data[0]">Hapus</a></td>
</tr>";
}
?>
</table>
Penjelasan, silakan tanya pada dosen, atau tanya di google...selanjutnya buat file baru lagi dengan nama proses-delete.php, kemudian isi dengan script php di bawah ini..
Pastikan, anda telah terhubung dengan database...
<?PHP
include("uji.php");
mysql_select_db("amburadul");
$sql="SELECT * FROM biodata WHERE no='$no'";
$hasil=mysql_query($sql);
$data=mysql_fetch_row($hasil);
?>
<table width="30%" class="akutabel">
<tr>
<td> FORM HAPUS DATA</td>
</tr>
<table width="30%" class="akutabel">
<tr>
<td>Labels</td>
<td>Isi</td>
</tr>
<tr>
<form id="form1" name="form1" method="post" action="">
<tr>
<td width="31%">NAMA</td>
<td width="69%"><label for="nama"></label>
<input name="nama" type="text" id="nama" value="<?php echo"$data[1]"?>" /></td>
</tr>
<tr>
<td bgcolor="#006600">NIM</td>
<td><label for="nim"></label>
<input name="nim" type="text" id="nim" value="<?php echo"$data[2]"?>" /></td>
</tr>
<tr>
<td bgcolor="#006600"> </td>
<td><label>
<div align="center"><strong>Anda Yakin Ingin Menghapus?</strong> <br />
<input type="submit" id="proses" name="Submit" value="YA" />
<input type="submit" id="proses" name="Submit2" value="BATAL" />
<input name="no" type="hidden" id="proses" value="<? echo"$data[0]"?>" />
</div>
</label></td>
</form>
</table></table>
<?
if($Submit){
$hapus="DELETE FROM biodata WHERE no='$no'";
$hasil=mysql_query($hapus);
if($hasil){
echo"<br>Data sukses di hapus";
}else{
echo"<br>Data Gagal Di hapus";
}
}
?>
Selamat Mencoba!!
0 comments:
Posting Komentar