3
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>Hitung Penjualan Barang</title> 6 </head> 7 <body> 8 <div align="center"><br />PERHITUNGAN PENJUALAN BARANG 2a.php</div> <br /><br /> 9 <form id="form1" name="form1" method="post" action="penjualan-2a.php"> 10 <table width="300" border="1" align="center"> 11 <tr> 12 <td>Kode Barang</td> 13 <td> 14 <select name="kode" id="kode"> 15 <option>---Silahkan Pilih--</option> 16 <option value="A01">A01 - Speaker</option> 17 <option value="B02">B02 - Mouse</option> 18 <option value="C03">C03 - Harddisk</option> 19 <option value="D04">D04 - Mouse Pad</option> 20 </select> </td> 21 </tr> 22 <tr> 23 <td>Jumlah Beli</td> 24 <td><input type="text" name="jumlah" id="jumlah"></td> 25 </tr> 26 </table> 27 <p> 28 <center><input type="submit" name="Hitung" id="Hitung" value="Hitung" /> 29 <input type="reset" name="Reset" id="Reset" value="Reset" /></center> 30 </p> 31 </form> 32 33 <?php 34 $jumlah=0; 35 $kode=""; 36 $nama=""; 37 $harga=0; 38 $jumlah=$_POST[jumlah]; 39 $kode=$_POST[kode]; 40 41 if ($kode=="A01"){ 42 $nama="Speaker"; 43 $harga=50000; 44 } 45 46 if ($kode=="B02"){ 47 $nama="Mouse"; 48 $harga=25000; C:\wamp\www\atol\Pertemuan 2\penjualan-2a.php: 1/3

penjualan-2a.pdf

Embed Size (px)

Citation preview

  • 1 2 3 4 5 Hitung Penjualan Barang 6 7 8 PERHITUNGAN PENJUALAN BARANG 2a.php 9 10 11 12 Kode Barang 13 14 15 ---Silahkan Pilih-- 16 A01 - Speaker 17 B02 - Mouse 18 C03 - Harddisk 19 D04 - Mouse Pad 20 21 22 23 Jumlah Beli 24 25 26 27 28 29 30 31 32 33
  • 49 } 50 51 if ($kode=="C03"){ 52 $nama="Hardisk"; 53 $harga=750000; 54 } 55 56 if ($kode=="D04"){ 57 $nama="Mouse Pad"; 58 $harga=5000; 59 } 60 61 $subtotal=$harga*$jumlah; 62 if ($subtotal>=100000){ 63 $diskon=0.15*$subtotal; 64 } 65 else 66 if ($subtotal>=50000){ 67 $diskon=0.1*$subtotal; 68 } 69 else 70 if ($subtotal>=25000){ 71 $diskon=0.05*$subtotal; 72 } 73 else 74 $diskon=0; 75 $totalbayar=$subtotal-$diskon; 76 ?> 77 78 79 80 81 82 Nama Barang 83 84 85 86 Harga Satuan 87 Rp. ; 88 89 90 Jumlah Beli 91 ; 92 93 94 Sub Total 95 Rp. ; 96 97 C:\wamp\www\atol\Pertemuan 2\penjualan-2a.php: 2/3

  • 98 Diskon 99 Rp. ;100 101 102 Total Bayar103 Rp. ;104 105 106 107 108 109

    C:\wamp\www\atol\Pertemuan 2\penjualan-2a.php: 3/3