Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "koneksi.php";
- $x = $_POST['x'];
- $semua_total = 0;
- $a = array();
- $kode=date("dmYHis");
- echo "Anda Telah Membeli :<br /><br />";
- for($i=1;$i<=$x;$i++){
- $hp =$_POST['hp'.$i];
- $trs = $_POST['jml'.$i];
- if($trs<=0){
- $o=0;
- $jml=$o;
- }
- else{
- $jml=$trs;
- }
- $sql = "select * from barang where nama='$hp'";
- $query = mysql_query($sql) or die(mysql_error());
- while($array=mysql_fetch_array($query)){
- $arr=$array['stok'];
- if($jml > $arr){?>
- <script>alert('Stok Kurang');</script>
- <script type="text/javascript">
- window.location='index.php';
- </script>
- <?php
- }else{
- $total = $array['harga']*$jml;
- echo "<strong>".$array['nama']."</strong>"." = ".$jml."<br/>Subtotal = Rp $total<br><br />"; $kurang=$array['stok']-$jml;
- //mysql_query("update barang set stok='$kurang' where nama='$array[nama]'");
- mysql_query("INSERT INTO penjualan (kode,nama,barang,jumlah,waktu) VALUES ('$kode','$_POST[napem]','$array[nama]','$jml',now())") or die(mysql_error());
- $semua_total += $total;
- array_push($a,$semua_total);
- }
- }
- $nilai = count($a)-1;
- }
- ?>
- </div><div class="col-md-8">
- <center>
- <h2> <?php echo "
-
-
-
-
- Total Biaya : Rp $a[$nilai] " ?>
Add Comment
Please, Sign In to add comment