Tapi disini saya gk sempat ngejelasin bagaimana caranya atau jalannya atau mulai darimana
darimana alurnya saya tidak bisa tulis disini.
Karna menurut untuk Penjelasan lebig detailnnya itu banyak di google yang sepadan atau yang ok lah istilahnya jadi saya minta saya gk bisa jelasin tapi klo memang gak keberatan kita bisa saling sharing kok bisa menggunakan E-mail saya.. Bisa juga langsung comment di bawah..
Untuk silahkan copy sourcekode dibawah untuk menguji hasilnya Klo eror silh commnet
Koneksi.php
<?php
class koneksi
{
function __construct(){
mysql_connect("localhost","root","");
mysql_select_db('tampan');
}
function Input($nama){
mysql_query("INSERT INTO tampan Values ('','$nama')");
}
function tampil_data(){
$data = mysql_query("select * from tampan");
while($d = mysql_fetch_array($data)){
$hasil[] = $d;
}
return $hasil;
}
function hapus($id){
mysql_query("DELETE FROM tampan WHERE id='$id'");
}
function edit($id){
$data = mysql_query("SELECT FROM tampan where id='$id'");
while($d = mysql_fetch_array($data)){
$hasil[] = $d;
}
return $hasil;
}
function update($id,$nama){
mysql_query("update tampan set nama='$nama' where id='$id'");
}
}
$koneksi = new koneksi();
?>
class koneksi
{
function __construct(){
mysql_connect("localhost","root","");
mysql_select_db('tampan');
}
function Input($nama){
mysql_query("INSERT INTO tampan Values ('','$nama')");
}
function tampil_data(){
$data = mysql_query("select * from tampan");
while($d = mysql_fetch_array($data)){
$hasil[] = $d;
}
return $hasil;
}
function hapus($id){
mysql_query("DELETE FROM tampan WHERE id='$id'");
}
function edit($id){
$data = mysql_query("SELECT FROM tampan where id='$id'");
while($d = mysql_fetch_array($data)){
$hasil[] = $d;
}
return $hasil;
}
function update($id,$nama){
mysql_query("update tampan set nama='$nama' where id='$id'");
}
}
$koneksi = new koneksi();
?>
Tambah.php
<?php
include('Koneksi.php');
$a = new koneksi();
?>
<html>
<head>
<title>input</title>
</head>
<body>
<form action="proses.php?proses=input" method="POST">
<input type="text" name="nama" placeholder="Masukkan Nama"/>
<input type="submit" value="Proses" />
</body>
</html>
include('Koneksi.php');
$a = new koneksi();
?>
<html>
<head>
<title>input</title>
</head>
<body>
<form action="proses.php?proses=input" method="POST">
<input type="text" name="nama" placeholder="Masukkan Nama"/>
<input type="submit" value="Proses" />
</body>
</html>
Proses.php
<?php
include('Koneksi.php');
$a = new Koneksi();
$input = $_GET["proses"];
if($input=='input'){
$a->Input($_POST['nama']);
}
?>
include('Koneksi.php');
$a = new Koneksi();
$input = $_GET["proses"];
if($input=='input'){
$a->Input($_POST['nama']);
}
?>
Tampilkan.php
<?php
include('Koneksi.php');
$db = new koneksi();
?>
<table border="1px solid">
<tr>
<td>No</td>
<td>Nama</td>
<td>Opsi</td>
</tr>
<?php
$no = 1;
foreach($db->tampil_data() as $x){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $x['nama']?></td>
<td>
<a href="edit.php?id=<?php echo $x['id'];?>&apa=edit">Edit</a>
<a href="hapus.php?id=<?php echo $x['id'];?>&apa=hapus">Hapus</a>
</td>
</tr>
<?php
}
?>
</table>
Proses_Hapus.php
<?php
include ('Koneksi.php');
$kon = new koneksi();
$aksi = $_GET['apa'];
if($aksi == "input"){
$kon->input($_POST['nama']);
header("location:Tampilkan.php");
}elseif($aksi == "hapus"){
$kon->hapus($_GET['id']);
header("location:Tampilkan.php");
}elseif($aksi == "update"){
$kon->update($_POST['id'],$_POST['nama']);
header("location:Tampilkan.php");
}
?>
include('Koneksi.php');
$db = new koneksi();
?>
<table border="1px solid">
<tr>
<td>No</td>
<td>Nama</td>
<td>Opsi</td>
</tr>
<?php
$no = 1;
foreach($db->tampil_data() as $x){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $x['nama']?></td>
<td>
<a href="edit.php?id=<?php echo $x['id'];?>&apa=edit">Edit</a>
<a href="hapus.php?id=<?php echo $x['id'];?>&apa=hapus">Hapus</a>
</td>
</tr>
<?php
}
?>
</table>
Proses_Hapus.php
<?php
include ('Koneksi.php');
$kon = new koneksi();
$aksi = $_GET['apa'];
if($aksi == "input"){
$kon->input($_POST['nama']);
header("location:Tampilkan.php");
}elseif($aksi == "hapus"){
$kon->hapus($_GET['id']);
header("location:Tampilkan.php");
}elseif($aksi == "update"){
$kon->update($_POST['id'],$_POST['nama']);
header("location:Tampilkan.php");
}
?>
Edit.php
include('Koneksi.php');
$db = new koneksi();
?>
<html>
<head>
<title>Edit</title>
</head>
<body>
<form action="hapus.php?update=update" method="POST">
<?php
foreach($db->edit($_GET['id']) as $d){
?>
<input type="hidden" name="id" value="<?php echo $d['id']?>">
<input type="text" name="nama" value="<?php echo $d['id']?>">
<input type="submit" value="Proses" />
<?php } ?>
</body>
</html>
$db = new koneksi();
?>
<html>
<head>
<title>Edit</title>
</head>
<body>
<form action="hapus.php?update=update" method="POST">
<?php
foreach($db->edit($_GET['id']) as $d){
?>
<input type="hidden" name="id" value="<?php echo $d['id']?>">
<input type="text" name="nama" value="<?php echo $d['id']?>">
<input type="submit" value="Proses" />
<?php } ?>
</body>
</html>
No comments:
Post a Comment
Comment Yang Jelas