Tugas Pemograman Web Dinamis ke 2
TUGAS PEMOGRAMAN WEB DINAMIS KE-2
NAMA : ARIEF NUR
PUTRANTO
NIM : 11018003
Langkah 1. Membuat database dengan data sebagai berikut :
Langkah 2. Buat script phpnya seperi berikut :
config.php
<?php
session_start();
ob_start();
$koneksi = mysql_connect("localhost", "root", "");
mysql_select_db("cart",$koneksi);
?>
testimonial.php
<?php require_once("cart.php"); ?>
<!DOCTYPE html>
<html>
<head>
<title>Mini Toko Online by Arief Nur Putranto</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<div id="header">
<h1>Mini Toko Online</h1>
<span>Create and Design by Arief Nur Putranto</span>
</div>
<div id="menu">
<a href="index.php">Home</a>
<a class="selected" href="testimonial.php">Testimonial</a>
<a href="admin/index.php">Admin</a>
</div>
<div id="sidebar">
<div class="title">» Keranjang Belanja</div>
<div class="body">
<?php cart(); ?>
</div>
<div class="title">» Tentang</div>
<div class="body">
Mini Toko Online di buat dengan PHP berdatabase MySQL.<br>
Keranjang di buat dengan menggunakan SESSION bukan Table Database untuk lebih mudah dan efisien.<br>
</div>
</div>
<div id="content">
<div class="title">» Testimonial</div>
Tulis Testimonial Anda di bawah ini:
<form action="" method="post">
<p><input type="text" name="nama" placeholder="Nama Lengkap" required></p>
<p><input type="text" name="mail" placeholder="Email Valid" required></p>
<p><textarea name="pesan" rows="5" cols="40" placeholder="Testimonial Anda" required></textarea></p>
<p><input type="submit" name="submit" value="Proses"></p>
</form>
</div>
<div class="clear"></div>
<div id="footer">
Copyright © 2013 Arief Nur Putranto
</div>
</div>
</body>
</html>
detail.php
<?php require_once("config.php"); ?>
<!DOCTYPE html>
<html>
<head>
<title>Mini
Toko Online by Arief Nur Putranto</title>
<link
rel="stylesheet" type="text/css"
href="style.css">
</head>
<body>
<div
id="container">
<div
id="header">
<h1>Mini
Toko Online</h1>
<span>Create
and Design by Arief Nur Putranto</span>
</div>
<div
id="menu">
<a
href="index.php">Home</a>
<a
class="selected"
href="testimonial.php">Testimonial</a>
</div>
<div
id="sidebar">
<div
class="title">» Tentang</div>
<div
class="body">
Mini
Toko Online di buat dengan PHP berdatabase MySQL.<br>
Keranjang
di buat dengan menggunakan SESSION bukan Table Database untuk lebih mudah dan
efisien.
</div>
</div>
<div
id="content">
<div
class="title">» Detail Keranjang Belanja</div>
<table
border="0" width="100%" cellspacing="0"
cellpadding="3">
<tr
style="background-color: #DDD;">
<th>No.</th>
<th>Nama
Barang</th>
<th>Jumlah</th>
<th>Harga
Satuan</th>
<th>Sub
Total</th>
<th>Opsi</th>
</tr>
<?php
//MENAMPILKAN
DETAIL KERANJANG BELANJA//
$no
= 1;
foreach($_SESSION
as $name => $value){
if($value
> 0){
if(substr($name,
0, 5) == 'cart_'){
$id
= substr($name, 5, (strlen($name)-5));
$get
= mysql_query('SELECT * FROM tw_produk WHERE
produk_id='.mysql_real_escape_string((int)$id));
while($get_row
= mysql_fetch_assoc($get)){
if($no
% 2 == 0){
$warna
= "#EAEAEA";
}
else {
$warna
= "#F4F4F4";
}
$sub
= $get_row['produk_harga'] * $value;
echo
'
<tr
bgcolor="'.$warna.'">
<td
align="center">'.$no.'</td>
<td
align="center">'.$get_row['produk_nama'].'</td>
<td
align="center">'.$value.'</td>
<td
align="right">Rp. '.$get_row['produk_harga'].'</td>
<td
align="right">Rp. '.$sub.'</td>
<td
align="center">
<a
href="detail.php?remove='.$id.'">[-]</a>
<a
href="detail.php?add='.$id.'">[+]</a>
<a
href="detail.php?delete='.$id.'" onclick="return confirm(\'Anda
Yakin?\');">[x]</a><br>
</td>
</tr>
';
$no++;
}
$total
+= $sub;
}
}
}
if($total
== 0){
echo
'<tr><td colspan="5" align="center">Keranjang
belanja masih kosong!</td></tr></table>';
echo
'<p><div align="right">
<a
href="index.php"><button>« Lanjutkan
Belanja</button></a>
</div></p>';
}
else {
echo
'
<tr
style="background-color: #DDD;"><td colspan="4"
align="right"><b>Total :</b></td><td
align="right"><b>Rp.
'.$total.'</b></td></td></td><td></td></tr></table>
<p><div
align="right">
<a
href="index.php"><button>« Lanjutkan
Belanja</button></a>
<a
href="checkout.php?total='.$total.'"><button>Checkout
»</button></a>
</div></p>
';
}
?>
<?php
//PROSES
TAMBAH JUMLAH PRODUK//
if(isset($_GET['add'])){
$qt
= mysql_query('SELECT produk_id, produk_jumlah FROM tw_produk WHERE
produk_id='.mysql_real_escape_string((int)$_GET['add']));
while($qt_row
= mysql_fetch_assoc($qt)){
if($qt_row['produk_jumlah']
!= $_SESSION['cart_'.$_GET['add']]){
$_SESSION['cart_'.$_GET['add']]+='1';
header("Location:
detail.php");
}
else {
echo
'<script language="javascript">alert("Stok barang tidak
mencukupi"); document.location="detail.php";</script>';
}
}
}
//PROSES
HAPUS 1 ITEM PRODUK//
if(isset($_GET['remove'])){
$_SESSION['cart_'.$_GET['remove']]--;
header("Location:
detail.php");
}
//PROSES
HAPUS SEMUA ITEM PRODUK//
if(isset($_GET['delete'])){
$_SESSION['cart_'.$_GET['delete']]='0';
header("Location:
detail.php");
}
?>
</table>
</div>
<div
class="clear"></div>
<div
id="footer">
Copyright
© 2013 Arief Nur Putranto
</div>
</div>
</body>
</html>
checkout.php
<?php require_once("cart.php"); ?>
<!DOCTYPE html>
<html>
<head>
<title>Mini
Toko Online by Arief Nur Putranto</title>
<link
rel="stylesheet" type="text/css"
href="style.css">
</head>
<body>
<div
id="container">
<div
id="header">
<h1>Mini
Toko Online</h1>
<span>Create
and Design by Arief Nur Putranto</span>
</div>
<div
id="menu">
<a
class="selected" href="index.php">Home</a>
<a
href="testimonial.php">Testimonial</a>
</div>
<div
id="sidebar">
<div
class="title">» Keranjang Belanja</div>
<div
class="body">
<?php
cart(); ?>
</div>
<div
class="title">» Tentang</div>
<div
class="body">
Mini
Toko Online di buat dengan PHP berdatabase MySQL.<br>
Keranjang
di buat dengan menggunakan SESSION bukan Table Database untuk lebih mudah dan
efisien.
</div>
</div>
<div
id="content">
<div
class="title">» Checkout » Data
Pengiriman</div>
Silahkan
isi data pengiriman barang / produk di bawah ini:
<form
action="finish.php" method="post">
<input
type="hidden" name="total" value="<?php echo
abs((int)$_GET['total']); ?>">
<p><input
type="text" name="nama" size="30"
placeholder="Nama Lengkap" required></p>
<p><textarea
name="alamat" rows="3" cols="40"
placeholder="Alamat Lengkap" required></textarea></p>
<p><input
type="submit" name="finish"
value="Finish"></p>
</form>
</div>
<div
class="clear"></div>
<div
id="footer">
Copyright
© 2013 Arief Nur Putranto
</div>
</div>
</body>
</html>
index.php
<?php require_once("cart.php"); ?>
<!DOCTYPE html>
<html>
<head>
<title>Mini
Toko Online by Arief Nur Putranto</title>
<link
rel="stylesheet" type="text/css"
href="style.css">
</head>
<body>
<div
id="container">
<div
id="header">
<h1>Mini
Toko Online</h1>
<span>Create
and Design by Arief Nur Putranto</span>
</div>
<div
id="menu">
<a
class="selected" href="index.php">Home</a>
<a
href="testimonial.php">Testimonial</a>
<a
href="admin/index.php">Admin</a>
</div>
<div
id="sidebar">
<div
class="title">» Keranjang Belanja</div>
<div
class="body">
<?php
cart(); ?>
</div>
<div
class="title">» Tentang</div>
<div
class="body">
Mini
Toko Online di buat dengan PHP berdatabase MySQL.<br>
Keranjang
di buat dengan menggunakan SESSION bukan Table Database untuk lebih mudah dan
efisien.<br>
</div>
</div>
<div
id="content">
<div
class="title">» Produk Terbaru</div>
<?php
produk(); ?>
</div>
<div
class="clear"></div>
<div
id="footer">
Copyright
© 2013 Arief Nur Putranto
</div>
</div>
</body>
</html>
cart.php
<?php
require_once("config.php");
if(isset($_GET['add'])){
$id =
mysql_real_escape_string((int)$_GET['add']);
$qt =
mysql_query("SELECT produk_id, produk_jumlah FROM tw_produk WHERE
produk_id='$id'");
while($qt_row
= mysql_fetch_assoc($qt)){
if($qt_row['produk_jumlah']
!= $_SESSION['cart_'.$_GET['add']] && $qt_row['produk_jumlah'] > 0){
$_SESSION['cart_'.$_GET['add']]+='1';
header("Location:
index.php");
}
else {
echo
'<script language="javascript">alert("Stok produk tidak
mencukupi!"); document.location="index.php";</script>';
}
}
}
function cart(){
foreach($_SESSION
as $name => $value){
if($value
> 0){
if(substr($name,
0, 5) == 'cart_'){
$id
= substr($name, 5, (strlen($name)-5));
$get
= mysql_query("SELECT * FROM tw_produk WHERE produk_id='$id'");
while($get_row
= mysql_fetch_assoc($get)){
$sub
= $get_row['produk_harga'] * $value;
echo
'<div style="font-size:11px; margin-bottom:-10px">»
'.$get_row['produk_nama'].' @ Rp. '.$get_row['produk_harga'].' X '.$value.' =
Rp. '.$sub.'</div><br>';
}
}
@$total
+= $sub;
}
}
if($total
== 0){
echo
'Keranjang Belanja Kosong!';
} else
{
echo
'<div style="text-align:right; font-size:11px;"><a
href="detail.php">» Detail
«</a></div>';
}
}
function produk(){
$sql =
mysql_query("SELECT * FROM tw_produk ORDER BY produk_id DESC");
if(mysql_num_rows($sql)
== 0){
echo
"Tidak ada produk!";
}else{
while($row
= mysql_fetch_assoc($sql)){
echo
'
<div
class="item">
<b>'.$row['produk_nama'].'</b>
<p>'.$row['produk_keterangan'].'</p>
<b>Harga:
'.$row['produk_harga'].' • Jumlah: '.$row['produk_jumlah'].'
• <a
href="index.php?add='.$row['produk_id'].'">Beli</a></b>
</div>
';
}
}
}
?>
finish.php
<?php require_once("cart.php"); ?>
<!DOCTYPE html>
<html>
<head>
<title>Mini
Toko Online Arief Nur Putranto</title>
<link
rel="stylesheet" type="text/css"
href="style.css">
</head>
<body>
<div
id="container">
<div
id="header">
<h1>Mini
Toko Online</h1>
<span>Create
and Design by Arief Nur Putranto</span>
</div>
<div
id="menu">
<a
class="selected" href="index.php">Home</a>
<a
href="testimonial.php">Testimonial</a>
</div>
<div
id="sidebar">
<div
class="title">» Tentang</div>
<div
class="body">
Mini
Toko Online di buat dengan PHP berdatabase MySQL.<br>
Keranjang di
buat dengan menggunakan SESSION bukan Table Database untuk lebih mudah dan
efisien.
</div>
</div>
<div
id="content">
<div
class="title">» Proses Belanja Selesai</div>
<?php
if($_POST['finish']){
session_destroy();
echo
'Terima kasih Anda sudah berbelanja di Toko Online kami. Dan berikut ini adalah
data yang perlu Anda catat.';
echo
'<p>Total biaya untuk pembelian Produk adalah'.$_POST['total'].' dan
biaya bisa di kirimkan melalui Rekening Bank BCA cabang Lamongan dengan nomor
rekening xxxx-xxxx-xxxx atas nama Si Pino.</p>';
echo
'<p>Dan barang akan kami kirim ke alamat di bawah ini:</p>';
echo
'<p>Nama Lengkap : '.$_POST['nama'].'<br>';
echo
'Alamat Lengkap : '.$_POST['alamat'].'</p>';
echo
'Terima Kasih.';
}else{
header("Location:
index.php");
}
?>
</div>
<div
class="clear"></div>
<div
id="footer">
Copyright
© 2013 Arief Nur Putranto
</div>
</div>
</body>
</html>
add_product.php
<?php
include "../config.php";
?>
<html>
<head>
<meta
http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<title>Mini
Toko Online</title>
<link
href="style/style.css" rel="stylesheet"
type="text/css">
</head>
<body>
<div
id="outline">
<div
id="header">
<h2>Mini
Toko Online</h2>
</div>
<div
id="content">
<?php
$sambung = mysql_connect("localhost",
"root", "") or die ("Gagal konek ke server.");
mysql_select_db("cart") or die ("Gagal
membuka database.");
?>
<p align="left"> Data barang</p>
<table border="1" align="left">
<tr align="left">
<td>ID</td>
<td>Nama</td>
<td>Keterangan</td>
<td>Harga</td>
<td>Jumlah</td>
<td>Pilihan</td>
</tr>
<?php
$query =
"select * from tw_produk";
$tabel = mysql_query($query, $sambung) or
die("gagal melakukan query");
while ($baris =
mysql_fetch_array($tabel)) {
?>
<tr>
<td><?php
echo $baris['produk_id']; ?></td>
<td><?php
echo $baris['produk_nama']; ?></td>
<td><?php
echo $baris['produk_keterangan']; ?></td>
<td><?php
echo $baris['produk_harga']; ?></td>
<td><?php
echo $baris['produk_jumlah']; ?></td>
<td><a
href="../admin/edit.php?produk_id=<?php echo $baris['produk_id'];
?>">Edit</a> |
<a
href="../admin/hapus.php?produk_id=<?php echo
$baris['produk_id'];?>">Hapus</a></td>
</tr>
<?php
};
mysql_close($sambung);
?>
</table>
</br>
</br>
</br>
</br>
</br>
<p
align="left"><a
href="../admin/form_tambah_data.php">Tambah
Data</a></p>
</div>
<?php
if
($_SESSION['id'] == TRUE)
{
?>
<div
id="sidebar">
<h3>Navigasi
Menu</h3>
<a
href="index.php">Dashboard</a><br>
<a
href="add_product.php">Produk</a><br>
<a
href="logout.php">Logout</a>
</div>
<?php
}
?>
<div
style="clear:both">
</div>
<div
id="footer">
<p>©<?php
echo date('Y')?> Membuat Toko Online dengan PHP dan MySQL created by <a
href="#">Arief Nur Putranto</a></p>
</div>
</div>
</body>
</html>
hapus.php
<html>
<head>
<title>Menghapus Data</title>
</head>
<body>
<?php
$sambung = mysql_connect("localhost",
"root", "") or die ("Gagal konek ke server.");
mysql_select_db("cart") or die ("Gagal
membuka database.");
$produk_id = $_GET['produk_id'];
mysql_query("delete from tw_produk where
produk_id='$produk_id'") or die ("Gagal menghapus data.");
//echo "delete from tw_produk where
produk_id='$produk_id'";
mysql_close($sambung);
?>
<p> Data sudah dihapus, Silahkan cek di <a
href="../admin/add_product.php">Tabel Data</a></p>
</body>
</html>
logout.php
<?php
session_start();
session_destroy();
header("location: index.php");
?>
Index.php
<?php
include "../config.php";
?>
<html>
<head>
<meta
http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<title>Mini
Toko Online </title>
<link
href="style/style.css" rel="stylesheet"
type="text/css">
</head>
<body>
<div
id="outline">
<div
id="header">
<h2>Mini
Toko Online</h2>
</div>
<div
id="content">
<?php
if
(empty ($_SESSION['id']))
{
?>
<h3>Login</h3>
<form
method="post" action="index.php">
<table>
<tr>
<td>Username</td>
<td><input
type="text" name="user"></td>
</tr>
<tr>
<td>Password</td>
<td><input
type="password" name="pass"></td>
</tr>
<tr>
<td></td>
<td><input
type="submit" value="login"></td>
</tr>
</table>
</form>
<?php
$user
=
empty($_POST['user'])?"":$_POST['user'];
$pswd
= empty($_POST['pass'])?"":$_POST['pass'];
if(isset($user)
or isset($pswd))
{
if($user
== "" or $pswd == "")
{
echo
"username dan atau password belum terisi";
}
else
{
$query
= mysql_query("select * from user where username = '$user' and password =
'$pswd'");
$row
= mysql_num_rows($query);
if($row
== 0)
{
echo
"Username dan atau password tidak ditemukan";
}
else
{
$data
= mysql_fetch_array($query);
$_SESSION['id']
= $data['id'];
echo
"<meta http-equiv='refresh' content='0;url=index.php' />";
}
}
}
}
else
{
?>
<h3>Welcome
Admin</h3>
<p>Ini
adalah halaman admin untuk mengelola toko anda</p>
<?php
}
?>
</div>
<?php
if
(!empty ($_SESSION['id']))
{
?>
<div
id="sidebar">
<h3>Navigasi
Menu</h3>
<a
href="index.php">Dashboard</a><br>
<a
href="add_product.php">Produk</a><br>
<a
href="logout.php">Logout</a>
</div>
<?php
}
?>
<div
style="clear:both">
</div>
<div
id="footer">
<p>©<?php
echo date('Y')?> Membuat Mini Toko Online dengan PHP dan MySQL created by
<a href="#">Arief Nur Putranto</a></p>
</div>
</div>
</body>
</html>
tambah_data.php
<html>
<head>
<title></title>
</head>
<body>
<?php
$sambung = mysql_connect("localhost",
"root", "") or die ("Gagal konek ke server.");
mysql_select_db("cart") or die ("Gagal
membuka database.");
$produk_id =
$_POST['produk_id'];
$produk_nama =
$_POST['produk_nama'];
$produk_keterangan =
$_POST['produk_keterangan'];
$produk_harga =
$_POST['produk_harga'];
$produk_jumlah =
$_POST['produk_jumlah'];
$query =
mysql_query("insert into tw_produk values ('$produk_id', '$produk_nama','$produk_keterangan',
'$produk_harga','$produk_jumlah')");
mysql_close($sambung);
?>
<p> Data sudah tersimpan, Silahkan cek di <a
href="../admin/add_product.php">Tabel Data</a></p>
</body>
</html>
edit.php
<html>
<head>
<title></title>
</head>
<body>
<?php
$sambung = mysql_connect("localhost",
"root", "") or die ("Gagal konek ke server.");
mysql_select_db("cart") or die ("Gagal
membuka database.");
$produk_id = $_GET['produk_id'];
$query = "select *from tw_produk where
produk_id='$produk_id'";
$result =
mysql_query($query, $sambung) or die("gagal melakukan query");
$buff =
mysql_fetch_array($result);
mysql_close($sambung);
?>
<form
name="form1" method="post"
action="edit_data.php">
<p align="left"> Edit Data</p>
<table boder="0" cellspacing="0"
style="borde-cellsapcing":collapse"
bordercolor="#111111" width="100%">
<tr>
<td
width="16%">ID</td>
<td
width="84%"><input type="hidden"
name="produk_id" value="<?php echo $buff['produk_id'];
?>" size="29"></td>
</tr>
<tr>
<td
width="16%">Nama</td>
<td
width="84%"><input type="text"
name="produk_nama" value="<?php echo $buff['produk_nama'];
?>" size="29"></td>
</tr>
<tr>
<td
width="16%">Keterangan</td>
<td
width="84%"><input type="text"
name="produk_keterangan" value="<?php echo
$buff['produk_keterangan']; ?>" size="29"></td>
</tr>
<tr>
<td
width="16%">Harga</td>
<td
width="84%"><input type="text"
name="produk_harga" value="<?php echo $buff['produk_harga'];
?>" size="29"></td>
</tr>
<tr>
<td
width="16%">Jumlah</td>
<td
width="84%"><input type="text"
name="produk_jumlah" value="<?php echo
$buff['produk_jumlah']; ?>" size="29"></td>
</tr>
<tr>
<td
width="16%"></td>
<td
width="84%"><input type="submit"
name="submit" size="29"
value="SIMPAN"></td>
</tr>
</table>
</form>
<p> Batal mengedit data. kembali ke <a
href="add_p.oduct.php">Tabel Data</a></p>
<body>
</body>
</html>
edit_data.php
<html>
<head>
<title></title>
</head>
<body>
<?php
$sambung =
mysql_connect("localhost", "root", "") or die
("Gagal konek ke server.");
mysql_select_db("cart")
or die ("Gagal membuka database.");
$produk_id = $_POST['produk_id'];
$produk_nama = $_POST['produk_nama'];
$produk_keterangan =
$_POST['produk_keterangan'];
$produk_harga = $_POST['produk_harga'];
$produk_jumlah = $_POST['produk_jumlah'];
$query = mysql_query("update
tw_produk set produk_nama='$produk_nama',produk_keterangan='$produk_keterangan',produk_harga='$produk_harga',produk_jumlah='$produk_jumlah'
where produk_id='$produk_id'");
echo "update tw_produk
set
produk_nama='$produk_nama',produk_keterangan='$produk_keterangan',produk_harga='$produk_harga',produk_jumlah='$produk_jumlah'
where produk_id='$produk_id'";
mysql_close($sambung);
?>
<p> Data sudah ter-update,
Silahkan cek di <a href="add_product.php">Tabel
Data</a></p>
</body>
</html>
form_tambah_data.php
<head>
<title></title>
</head
<body>
<form name="form1"
method="post" action="../admin/tambah_data.php">
<p align="left">
Masukan Data barang</p>
<table boder="0"
cellspacing="0" style="borde-cellsapcing":collapse"
bordercolor="#111111" width="100%">
<tr>
<td
width="16%">ID</td>
<td
width="84%"><input type="text"
name="produk_id" size="29"></td>
</tr>
<tr>
<td width="16%">NAMA</td>
<td
width="84%"><input type="text"
name="produk_nama" size="29"></td>
</tr>
<tr>
<td
width="16%">KETERANGAN</td>
<td
width="84%"><input type="text"
name="produk_keterangan" size="29"></td>
</tr>
<tr>
<td width="16%">HARGA</td>
<td
width="84%"><input type="text"
name="produk_harga" size="29"></td>
</tr>
<tr>
<td
width="16%">JUMLAH</td>
<td
width="84%"><input type="text"
name="produk_jumlah" size="29"></td>
</tr>
<tr>
<td
width="16%"></td>
<td
width="84%"><input type="submit"
name="submit" size="29"
value="SIMPAN"></td>
</tr>
</table>
</form>
<p> Untuk melihat data yang
sudah tersimpan, Silahkan cek di <a
href="../admin/tampil.php">Tabel Data</a></p>
</table>
</body>
</html>
report.php
<?php
include "../config.php";
?>
<html>
<head>
<meta
http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<title>Toko
Online Sederhana created by tukangbolos</title>
<link
href="style/style.css" rel="stylesheet"
type="text/css">
</head>
<body>
<div
id="outline">
<div
id="header">
<h2>Toko
Online Sederhana</h2>
</div>
<div
id="content">
<?php
if
($_SESSION['id'] == FALSE)
{
echo
"<meta http-equiv='refresh' content='0;url=index.php' />";
}
else
{
?>
<h3>Report
Order Product</h3>
<?php
$query
= mysql_query("SELECT * from order_product");
$row
= mysql_num_rows($query);
if($row
== 0)
{
echo
"<b>Tidak ada hasil Penjualan</b>";
}
else
{
?>
<table
border="1">
<tr>
<td
width="5%">No.</td>
<td
width="15%">ID Barang</td>
<td
width="20%">Nama</td>
<td
width="15%">Email</td>
<td
width="30%">Alamat</td>
<td
width="10%">Nomor HP</td>
<td
width="5%">Status</td>
</tr>
<?php
$i
= 0;
while($data=mysql_fetch_array($query))
{
$i++
?>
<tr>
<td><?=
$i?></td>
<td><?=$data['id_product']?></td>
<td><?=$data['name']?></td>
<td><?=$data['email']?></td>
<td><?=$data['address']?></td>
<td><?=$data['number_phone']?></td>
<td><?=$data['status']?></td>
</tr>
<?php
}
?>
</table>
<?php
}
}
?>
</div>
<?php
if
($_SESSION['id'] == TRUE)
{
?>
<div
id="sidebar">
<h3>Navigasi
Menu</h3>
<a
href="index.php">Dashboard</a><br>
<a
href="add_product.php">Add Product</a><br>
<a
href="add_category.php">Add Category</a><br>
<a
href="report.php">Report</a><br>
<a
href="logout.php">Logout</a>
</div>
<?php
}
?>
<div
style="clear:both">
</div>
<div
id="footer">
<p>©<?php
echo date('Y')?> Membuat Toko Online dengan PHP dan MySQL created by <a
href="#">arief nur putranto</a></p>
</div>
</div>
</body>
</html>
tampil.php
<html>
<head>
<title></title>
</head>
<body>
<?php
$sambung =
mysql_connect("localhost", "root", "") or die
("Gagal konek ke server.");
mysql_select_db("cart")
or die ("Gagal membuka database.");
?>
<p align="left">
Data barang</p>
<table border="1"
align="left">
<tr align="left">
<td>Produk ID</td>
<td>Produk Nama</td>
<td>Produk Keterangan</td>
<td>Produk Harga</td>
<td>Produk
Jumlah</td>
<td>plihan</td>
</tr>
<?php
$query = "select * from
tw_produk";
$result =
mysql_query($query, $sambung) or die("gagal melakukan query");
while ($buff = mysql_fetch_array($result)) {
?>
<tr>
<td><?php echo $buff['produk_id']; ?></td>
<td><?php echo $buff['produk_nama']; ?></td>
<td><?php
echo $buff['produk_keterangan']; ?></td>
<td><?php echo $buff['produk_harga']; ?></td>
<td><?php
echo $buff['produk_harga']; ?></td>
<td><?php
echo $buff['produk_jumlah']; ?></td>
<td><a href="../belajar/edit.php?kode=<?php echo
$buff['kode']; ?>">Edit</a> |
<a href="../belajar/hapus.php?kode=<?php echo
$buff['kode'];?>">Hapus</a></td>
</tr>
<?php
};
mysql_close($sambung);
?>
</table>
</br>
</br>
</br>
</br>
</br>
<p align="left"><a
href="../belajar/form_tambah_data.php">Tambah
Data</a></p>
</body>
</html>
Untuk tampilannya sebagai berikut :