Pengaturan

Gambar

Lainnya

Tentang KASKUS

Pusat Bantuan

Hubungi Kami

KASKUS Plus

© 2024 KASKUS, PT Darta Media Indonesia. All rights reserved

mallarangengAvatar border
TS
mallarangeng
[HELP] Memindahkan record dari tebel produk ke tmp_penjualan
Selamat pagi gan, mohon bantuanya gan, ane baru belajar PHP, cara untuk memnidahkan record dari tabel produk ke tabel tmp_penjualan, ketika button [beli] di klik gmana ya ?, cara yang ane pake gak berhasil gan, dimana record yang paling bawah lah yang hanya bisa masuk ke tabel tmp_penjualan ketika button beli di klik, sedangkan record yang diatasnya tidak bisa masuk ke tabel tmp_penjualan,

Mohon bantuan dar pencerahan untuk perbaikan gan emoticon-Berduka (S)

skrip ane produk.php
PHP Code:
<html>
<head>
 <title>Ecommerce</title>
 </head>
 <body>
 <h2>PRODUK</h2>
 
 <table id="box-table-a" width="399" border="1" cellspacing="0" cellpadding="0">
  <tr>
  <th scope="col">NO</th>
  <th scope="col">KODE</th>
  <th scope="col">NAMA PRODUK</th>
   <th scope="col">HARGA</th>
   <th scope="col">SATUAN</th>
   <th scope="col">JUMBEL</th>
    <th scope="col">BELI</th>
   </tr>
   <form action="tmp_save.php" enctype="multipart/form-data" method="post">
    <?php
include"koneksi.php";
$tampil=mysql_query ("select * from produk ");
$no=0;
while (
$data=mysql_fetch_array($tampil))
{
?>
 
  <tr>
  
    <td height="25"><center><?php echo $no=$no+1;?></center></td>
    <td>&nbsp;<?=$data['kd_produk']?><input type="hidden" name="kd_produk" value="<?=$data['kd_produk']?>"></td>
    <td align="left"><?=$data['nm_produk']?></td>
    <td width="18%"><?=$data['harga']?></td>
    <td width="13%" align="center"><?=$data['satuan']?></td>
    <td width="6%" align="center"><input type="text" name="jumlah" value="" size="5"></td>
    <td width="6%" align="center"><input type="submit" name="kirim" value="Beli"></td>
  </tr>
  <?php
  
}
  
?>
  </form>
</table>

<h2>TEMPORARI</h2>
<table id="box-table-a" width="511" border="1" cellspacing="0" cellpadding="0">
  <tr>
  <th scope="col">NO</th>
  <th scope="col">KODE</th>
  <th scope="col">NAMA PRODUK</th>
   <th scope="col">HARGA</th>
   <th scope="col">SATUAN</th>
   <th scope="col">JUMBEL</th>
   <th scope="col">JUMLAH</th>
    <th scope="col">EDIT</th>
  </tr>
    <?php
include"koneksi.php";
$tampil=mysql_query ("SELECT produk.kd_produk, produk.nm_produk, produk.harga, produk.satuan,
tmp_penjualan.kd_produk,jumlah
FROM produk,tmp_penjualan
WHERE produk.kd_produk = tmp_penjualan.kd_produk
"
);
$no=0;
while (
$data=mysql_fetch_array($tampil))
{
$hasil=$data['harga']*$data['jumlah'];
?>
 
  <tr>
    <td height="25"><center><?php echo $no=$no+1;?></center></td>
    <td align="left"><?=$data['kd_produk']?></td>
    <td align="left"><?=$data['nm_produk']?></td>
    <td width="18%"><?=$data['harga']?></td>
    <td width="13%" align="center"><?=$data['satuan']?></td>
    <td width="6%" align="center"><?=$data['jumlah']?></td>
    <td width="6%" align="center"><? echo $hasil ?></td>
    <td width="6%" align="center"><a class="kolom" href="?page=conten_edit&id=<?=$data['id']?>">Edit</a></td>
  </tr>
  <?php
  
}
  
?>
</table>
</body>
 </html>


tmp_save.php
PHP Code:
<?php
include"koneksi.php";
$kd_produk=$_POST['kd_produk'];
$jumlah=$_POST['jumlah'];
$ip=$_POST['ip'];
$simpan=mysql_query("insert into tmp_penjualan(kd_produk,jumlah,ip)values('$kd_produk','$jumlah','$ip');");
mysql_query($simpan,$koneksi);
echo
"<meta http-equiv='refresh' content='0; url=produk.php?succes'>";
?>


Diubah oleh mallarangeng 04-12-2013 00:43
0
887
6
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Urutan
Terbaru
Terlama
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Komunitas Pilihan