koneksi.php
<?
$koneksi=mysql_connect("localhost","root","password") or die (mysql_error());
$db="akademik_12099939";
mysql_select_db($db,$koneksi)or die(mysql_error());
?>
tampil.php
html>
<head>
<title>Daftar anggota Klub Hebat</title>
</head>
<body>
<?
include "koneksi.php";
$sql="select nama,email,komentar from buku_tamu";
if(!$query=mysql_query($sql))echo mysql_error();
while($row=mysql_fetch_array($query)){
echo "nama :$row[nama]<br>";
echo "email :$row[email]<br>";
echo "komentar :$row[komentar]<br>";
echo"<hr>";
}
?>
<br>
<a href="buku_tamu.php">Isi komentar lagi?...</a>
</body>
</html>
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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?
include"koneksi.php";
$sql="select*from mhs where nim='$E'";
$qry=mysql_query($sql,$koneksi)or die(mysql_error());
while($data=mysql_fetch_array($qry))
{
$nim=$data[0];
$nama=$data[1];
$jurusan=$data[2];
$kelas=$data[3];
?>
<form action="update.php" method="post">
<font color="#0000FF" size="4"><strong>Data Yang Akan Diperbaiki nih ^_^ </strong></font><strong></strong>
<table width="90%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td width="39%">Nama Lengkap</td>
<td width="61%"> <input name="nama" type="text" id="nama2" value="<? echo $nama;?>"></td>
</tr>
<tr>
<td>Jurusan</td>
<td>
<select name="jurusan" id="jurusan" >
<option value="MI">MI</option>
<option value="KA">KA</option>
<option value="TK">TK</option>
</select></td>
</tr>
<tr>
<td>Kelas</td>
<td>
<input name="kelas" type="text" id="kelas" value="<? echo $kelas; ?>"></td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input name="Update" type="submit" id="Update" value="Update">
<input name="nim" type="hidden" id="nim" value="<? echo $nim; ?>">
</div></td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>
update.php
<?php
include "koneksi.php";
$query=mysql_query("update mhs set nama='$nama', jurusan='$jurusan', kelas='$kelas' where nim='$nim'",$koneksi)
or die ("Gagal ".mysql_error());
if($query){
?>
<script language="javascript">
alert('Data Sudah Diperbaiki Yah!')
</scripp-equiv="refresh" content="0; url=tampil.php">
<?
}
?>
hapus.php
<?php
include "koneksi.php";
$query=mysql_query("delete from mhs where nim='$H'",$koneksi)
or die ("Gagal ".mysql_error());
if($query){
?>
<script language="javascript">
alert('Data Sudah Terhapus')
</script>
0 comments:
Post a Comment
No Coment No Spam!!!