Terbaru dan Populer

Sabtu, 28 Juli 2012

PHP HTML Contoh Daftar Barang

Daftar barang-barang
Gambar data base





Tambah data
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>tambah_barang</title>
</head>
<b><marquee>insrt barang-barang baru</marquee>
<hr>
<body>
<form method="post">
kode_barang
<input type="text" name="kode_barang" value="" />
nama_barang
<input type="text" name="nama_barang" value="" />
jumlah
<input type="text" name="jumlah" value="" />
hargga_barang
<input type="text" name="hargga_barang" value="" />
<input type="submit" name="simpan" value="simpan" />
<input type="reset" name="Batal"value="Batal"/>
</form>
<?php

if (isset  ($_POST['simpan']))
{
$host="localhost";
$user="root";
$pass="";
$konek= mysql_connect($host,$user,$pass);
mysql_select_db('ariez1',$konek) or die ('tidak connect');
$kode_barang=$_POST['kode_barang'];
$nama_barang=$_POST['nama_barang'];
$jumlah=$_POST['jumlah'];
$hargga_barang=$_POST['hargga_barang'];
$sql="insert into barang (kode_barang,nama_barang,jumlah,hargga_barang)
values ('$kode_barang','$nama_barang','$jumlah','$hargga_barang')";
if(mysql_query($sql))
{
echo "OK_lanjutkan";
}else
echo" NO_harap ulangi lagi !!!";
}
?>
<a href="http://localhost/php%20barang%20ku/">kembali ke home</a>
</body>
</html>
</html>
Cari Data
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>cari </title>
<b><marquee>Cari_ barang-barang </marquee>
<hr>
</head>
<body>
<form method="post" action="">
kode_barang
<input type="text" name="kode_barang" value="" />
<input type="submit" name="cari" value="cari" />
</form>
<?php
if(isset($_POST['cari']))
{
$kode_barang=$_POST['kode_barang'];
$konek=mysql_connect('localhost','root','');
mysql_select_db('ariez1',$konek);
$sql="select * from barang where kode_barang='$kode_barang'";
$rs=mysql_query($sql);
if(mysql_num_rows($rs))
{
$row=mysql_fetch_assoc($rs);
?>
<form method="post" action="">
kode_barang
<input type="text" name="kode_barang" value="<?php echo $row['kode_barang']; ?>" />
nama_barang
<input type="text" name="nama_barang" value="<?php echo $row['nama_barang']; ?>" />
jumlah
<input type="text" name="jumlah" value="<?php echo $row['jumlah']; ?>" />
hargga_barang
<input type="text" name="hargga_barang" value="<?php echo $row['hargga_barang']; ?>" />
</form>
<?php  }else
echo "Data Tidak Ada";
}?>
<br/>
<a href="http://localhost/php%20barang%20ku/">kembali ke home</a>
</body>
</html>
Edit Data
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title> edit</title>
<b><marquee>Update barang-barang </marquee>
<hr>
</head>
<body>
<form method="post" action="">
kode_barang
<input type="text" name="kode_barang" value="" />
<input type="submit" name="cari" value="cari" />

</form>
<?php
if(isset($_POST['cari']))
{
$kode_barang=$_POST['kode_barang'];
$konek=mysql_connect('localhost','root','');
mysql_select_db('ariez1',$konek);
$sql="select * from barang where kode_barang='$kode_barang'";
$rs=mysql_query($sql);
if(mysql_num_rows($rs))
{
$row=mysql_fetch_assoc($rs);
?>
<form method="post" action="">
kode_barang
<input type="text" name="kode_barang" value="<?php echo $row['kode_barang']; ?>" />
nama_barang
<input type="text" name="nama_barang" value="<?php echo $row['nama_barang']; ?>" />
jumlah
<input type="text" name="jumlah" value="<?php echo $row['jumlah']; ?>" />
hargga_barang
<input type="text" name="hargga_barang" value="<?php echo $row['hargga_barang']; ?>" />
edit
<input type="submit" name="edit" value="" />
</form>
<?php  }else
echo "Data Tidak Ada";
}?>
<?php
if(isset($_POST['edit']))
{
$kode_barang=$_POST['kode_barang'];
$nama_barang=$_POST['nama_barang'];
$jumlah=$_POST['jumlah'];
$hargga_barang=$_POST['hargga_barang'];
$konek=mysql_connect('localhost','root','');
mysql_select_db('ariez1',$konek);
$sql="update barang set nama_barang='$nama_barang',jumlah='$jumlah',hargga_barang='$hargga_barang'
where kode_barang='$kode_barang'";
if(mysql_query($sql))
echo "Edit Data Sucsess";
else
echo "Gagal";
}
?>
<br/>
<a href="http://localhost/php%20barang%20ku/">kembali ke home</a>
</body>
</html>
Delete
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>delete</title>
<b><marquee>Delete barang-barang </marquee>
<hr>
</head>
<body>
<form method="post" action="">
kode_barang
<input type="text" name="kode_barang" value="" />
<input type="submit" name="cari" value="cari" />
</form>
<?php
if(isset($_POST['cari']))
{
$kode_barang=$_POST['kode_barang'];
$konek=mysql_connect('localhost','root','');
mysql_select_db('ariez1',$konek);
$sql="select * from barang where kode_barang='$kode_barang'";
$rs=mysql_query($sql);
if(mysql_num_rows($rs))
{
$row=mysql_fetch_assoc($rs);

?>
<form method="post" action="">
kode_barang
<input type="text" name="kode_barang" value="<?php echo $row['kode_barang']; ?>" />
nama_barang
<input type="text" name="nama_barang" value="<?php echo $row['nama_barang']; ?>" />
jumlah
<input type="text" name="jumlah" value="<?php echo $row['jumlah']; ?>" />
hargga_barang
<input type="text" name="hargga_barang" value="<?php echo $row['hargga_barang']; ?>" />
delete
<input type="submit" name="delete" value="delete" />
</form>
<?php  }else
echo "Data Tidak Ada";
}?>
<?php
if (isset($_POST['delete']))
{
$kode_barang=$_POST['kode_barang'];
$nama_barang=$_POST['nama_barang'];
$jumlah=$_POST['jumlah'];
$hargga_barang=$_POST['hargga_barang'];
$konek=mysql_connect('localhost','root','');
mysql_select_db('ariez1',$konek);
$sql="delete from barang where kode_barang='$kode_barang'";

if(mysql_query($sql))
echo "Delete Data Sucsess";
else
echo "Gagal";
}
?>
<br/>
<a href="http://localhost/php%20barang%20ku/">kembali ke home</a>
</body>
</html>
Tampil
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>tampil data</title>
<b><marquee>barang-barang yang akan di beli</marquee>
<hr>
<body>
<marquee>

<?php
$konek=mysql_connect('localhost','root','');
mysql_select_db('ariez1',$konek);
$sql="select * from barang";
$rs=mysql_query($sql);
?>
<br/>
<table border='3'>
<tr>
<td>kode_barang</td><td>Nama_barang</td><td>Jumlah</td><td>hargga_barang</td>
</tr>
<?php              while($row=mysql_fetch_assoc($rs))
{?>
<tr>
<td><?php echo $row['kode_barang']; ?></td>
<td><?php echo $row['nama_barang']; ?></td>
<td><?php echo $row['jumlah']; ?></td>
<td><?php echo $row['hargga_barang']; ?></td>
</tr>
<?php              }
?>
</table>
<br/>
&copy;copyright. ariez irwanto
<br/>
<br/>
<a href="http://localhost/php%20barang%20ku/">kembali ke home</a>
</marquee>
</body>
</html>
=====================================================================
indx
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>tampil data</title>
<b><marquee>Daftar barang-barang yang ada</marquee>
<hr>
<h2>youariez</h2>
<a href="http://localhost/php%20barang%20ku/" </a>bernda
<br/>
<br/>
<body>
<a href="barang.php">||/inset data/||</a>
<a href="edit.php">||/edit/||</a>
<a href="delete.php" >||/delete/||</a>
<a href="cari.php" >||/cari/||</a>
<a href="tampil.php" >||/tampil/||</a>
</head>
<body>
<br/>
<br/>
<?php
$konek=mysql_connect('localhost','root','');
mysql_select_db('ariez1',$konek);
$sql="select * from barang";
$rs=mysql_query($sql);
?>
<table border='1'>
<tr>
<td>kode_barang</td><td>Nama_barang</td><td>Jumlah</td><td>hargga_barang</td>
</tr>
<?php              while($row=mysql_fetch_assoc($rs))
{?>
<tr>
<td><?php echo $row['kode_barang']; ?></td>
<td><?php echo $row['nama_barang']; ?></td>
<td><?php echo $row['jumlah']; ?></td>
<td><?php echo $row['hargga_barang']; ?></td>
</tr>
<?php              }
?>
</table>
</body>
</html>
Hasil


1 komentar:

  1. terimakasih banyak udah sangat membantu tugas kuliah saya :)

    BalasHapus

Designed By Aris irwanto