Download pdf - HitungJual

Transcript
Page 1: HitungJual

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>Penjualan</title> 6 <style type="text/css"> 7 <!-- 8 .style1 { 9 color: #FFFF00;10 font-weight: bold;11 }12 -->13 </style>14 </head>15 16 <body>17 <table width="376" height="104" border="1">18 <tr>19 <td colspan="5" bgcolor="#009900"><div align="center" class="style1">PENJUALAN BARANG</div></td>20 </tr>21 <tr bgcolor="#CCCCCC">22 <td width="26"><div align="center"><strong>No</strong></div></td>23 <td width="103"><div align="center"><strong>Nama Barang</strong></div></td>24 <td width="79"><div align="center"><strong>Harga</strong></div></td>25 <td width="48"><div align="center"><strong>Jumlah</strong></div></td>26 <td width="86"><div align="center"><strong>Sub Total</strong></div></td>27 </tr>28 29 <?php30 $no=0;31 $total=0;32 $totqty=0;33 34 $harga=$_POST["harga"];35 $nama=$_POST["nama"];36 $qty=$_POST["qty"];37 38 for ($i=0; $i<count($nama);$i++)39 {40 if ($qty[$i]!=0)41 {42 $no++;43 $subtotal=$qty[$i]*$harga[$i]; 44 echo "<tr>45 <td align=center>$no</td>46 <td>$nama[$i] </td>47 <td align=right> Rp. ".48 number_format($harga[$i],0) . "</td>49 <td align=center>$qty[$i]</td>

C:\wamp\www\atol\Pertemuan 3\HitungJual.php: 1/2

Page 2: HitungJual

50 <td align=right> Rp. ".51 number_format($subtotal,0) . "</td>52 </tr>";53 $totqty=$totqty+$qty[$i];54 $total=$total+$subtotal;55 56 }57 } 58 ?> 59 <tr bgcolor="#CCCCCC">60 <td colspan="3"><div align="right"><strong>Total</strong></div></td>61 <td><div align="center"><?php echo number_format($totqty,0); ?></div></td>62 <td><div align="right">Rp. <?php echo number_format($total,0); ?></div></td>63 </tr>64 </table>65 66 </body>67 </html>

C:\wamp\www\atol\Pertemuan 3\HitungJual.php: 2/2