Latihan php

Save.php
"http://www.w3.org/TR/html4/loose.dtd">
Untitled Document


include_once("koneksi.php");
mysql_query("insert into mahasiswa values('$nim','$nm','$jk','$tgl','$jur','$alm','$hb')",$koneksi);
echo"
terimakasih data telah disimpan
";?>

back

next
Hapus.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_once("koneksi.php");
$sql="delete from mahasiswa where nim='$nim'";
$qry=mysql_db_query("bsi_krw",$sql,$koneksi);
print"<br>Data Terhapus<br>";
print"<a href='list.php'>Show</a>";
?>
</body>
</html>

Konek.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?
$koneksi=mysql_connect("localhost","root","password")or die("koneksi gagal".mysql_eror());
if($koneksi){mysql_select_db("bsi_krw",$koneksi)or die("database gagal dibuka".mysql_eror());
echo"<font color=red>SELAMAT DATANAG BOS</font>";} ?>
</body>
</html>

List.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_once("koneksi.php");
echo"<br><h3>Daftar Mahasiswa";
$sql="select nim,nm,jk,tgl,jur,alm,hb from mahasiswa";
$qry=mysql_db_query("bsi_krw",$sql,$koneksi)or die("ada salah");
echo"<pre>
<table border='5'>
<tr><td>Nim<td>Nama<td>Jenis Kelamin<td>Tanggal Lahir<td>Jurusan<td>Alamat<td>Hobi<td>Hapus";

while($row=mysql_fetch_row($qry))
{    echo"<tr><td>$row[0]<td>$row[1]<td>$row[2]<td>$row[3]<td>$row[4]<td>$row[5]<td>$row[6]<td>$row[7]
    <a href='hapus.php?nim=$row[0]'>hapus</a>";
    echo"<br>";
}
echo"</table></pre>";
print"<a href='input.php'>masukan data lagi</a><br>";
?>
</body>
</html>
Share
»»  Baca lagi... Best Regard,
Image Hosted by ImageShack.us