Senin, 09 Januari 2012

Database Susu Input dan Output

NAMA  : JULIANTO SAPUTRA
NIM      : 18095597
KELAS  : 12.5C.04



LISTING INPUT_SUSU.PHP

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body bgcolor="blue" text="white">
<form action="output_susu.php" method="post">
<table size=100% border=5><tr><td>
<h1>Toko Susu Sukses Selalu</h1>
<pre>                       
Nama.Pembeli                   :<input type="text" name="nama">
Jenis Susu                            :<select name="kode">
                                                <option value="DCW01">DCW01</option>
                                                  <option value="BND02">BND02</option>
                                                 <option value="NST03">NST03</option></select>
Jumlah               :<input type="text"name="jumlah"> Kaleng <br>
<input type="submit" value="Save"><input type="reset" value="Cancel">

</body>
</html>

TAMPILAN INPUT_SUSU.PHP


LISTING OUTPUT_SUSU.PHP

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body bgcolor="blue" text="white">
<?
if($kode=="DCW01")
{
    $jenis="Susu Dancow";
    $harga=30000;
}
elseif($kode=="BND02")
{
    $jenis="Susu Bendera";
    $harga=35000;
}
else
{
    $jenis="Susu Nestle";
    $harga=32000;
}
$total=$jumlah*$harga;
$koneksi=mysql_connect("localhost","root","password");
if ($koneksi)
{
    mysql_select_db("latihan_julianto_18095597");
    echo"<pre>";
    echo"<h1>Struk Penjualan Susu</h1>";
    echo"<hr><b>";
    echo"Nama Pembeli        :$nama <br>";
    echo"Jenis Susu          :$jenis<br>";
    echo"Harga               :$harga<br>";
    echo"Jumlah Beli         :$jumlah<br>";
    echo"Total Harga         :$total<br>";
    echo"<hr>";
    $sqlstr="insert into susu values('$nama','$jenis','$jumlah','$harga','$total')";
    $hasil=mysql_query($sqlstr,$koneksi);
    echo"<h1>";
    echo"Sudah Berhasil Disimpan</h1>";
    echo "<table size=100% border=1>";
    echo "<tr><td>Nama.Pembeli</td><td>Jenis.Susu</td><td>Harga</td><td>Jumlah.Beli</td><td>Total.Harga</td></tr>";
    $sqlstr2=mysql_query("select * from susu");
    while ($hasil=mysql_fetch_row($sqlstr2))
    {
        echo"<tr>";
        echo"<td>$hasil[0]</td>";
        echo"<td>$hasil[1]</td>";
        echo"<td>$hasil[2]</td>";
        echo"<td>$hasil[3]</td>";
        echo"<td>$hasil[4]</td>";
        echo"</tr>";
    }
    echo"</table>";
    mysql_close($koneksi);}
    else
    echo "Anda Gagal";
    ?>
    <br>
    <a href="input_susu.php">Lagi</a>
       
</body>
</html>

TAMPILAN OUTPUT_SUSU.PHP


Tidak ada komentar:

Posting Komentar