drimlen

QTY

May 31st, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.22 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.   <title></title>
  5. </head>
  6.  
  7. <body>
  8.  
  9. <?php
  10. /*
  11. setelah di klik.. lebih baik apa yg km klik nongol di atas jgn
  12. dibawah!!         asd
  13. */
  14.  
  15.  
  16.         echo"<form method=\"post\" name=\"update\">";
  17.             echo"<table align=\"center\" border=\"1\">";
  18.                 echo"<tr bgcolor=\"iceblue\">";
  19.                     echo"<td align=\"center\"> <font face=\"calibri\" color=\"white\">";
  20.                     echo"Nama Produk</td>";
  21.                     echo"<td align=\"center\"> <font face=\"calibri\" color=\"white\">";
  22.                     echo"Qty</td>";
  23.                 echo"</tr>";
  24.                         $conn = mysql_connect("localhost","root","dancing01")or
  25.                             die(mysql_error()."Cannot connect to server");
  26.  
  27.                         $data = mysql_select_db("warung",$conn)or
  28.                             die(mysql_error()."Cannot connect to database");
  29.  
  30.                         $sql = "select merk_produk from master_produk";
  31.                         $result = mysql_query($sql, $conn)or
  32.                             die(mysql_error()."An error occured in SQL query <br> Query: $sql");
  33.  
  34.                         while($line = mysql_fetch_row($result)){
  35.  
  36.                         $merk = $line[0];
  37.  
  38.                         echo"<tr bgcolor=\"iceblue\">";
  39.                         echo"<td><font face=\"calibri\" color=\"white\">";
  40.                             echo"<input type=\"checkbox\" name='produk[$merk]' value=\"$merk\" \>$merk<br>";
  41.                         echo"</td>";
  42.                         echo"<td>";
  43.                             echo"<input size=\"2%\" type=\"text\" name=\"qty\">";
  44.                         echo"</td>";
  45.                         echo"</tr>";
  46.                     }
  47.                         mysql_close($conn);
  48.                 echo"<tr bgcolor=\"iceblue\">";
  49.                     echo"<td colspan=\"2\" align=\"center\">";
  50.                         echo"<input type=\"submit\" name=\"tampil\" value=\"Tampilkan Detil Pembayaran\">";
  51.                     echo"</td>";
  52.                 echo"</tr>";
  53.             echo"</table>";
  54.         echo"</form>";
  55.  
  56.                     if($_POST)
  57.             {
  58.  
  59.                     echo"<table align=\"center\">";
  60.                         echo"<tr bgcolor=\"iceblue\">";
  61.                             echo"<td align=\"center\"><font face=\"calibri\" color=\"white\">";
  62.                             echo"No</td>";
  63.                             echo"<td align=\"center\"><font face=\"calibri\" color=\"white\">";
  64.                             echo"Produk</td>";
  65.                             echo"<td align=\"center\"><font face=\"calibri\" color=\"white\">";
  66.                             echo"Kategori</td>";
  67.                             echo"<td align=\"center\"><font face=\"calibri\" color=\"white\">";
  68.                             echo"Harga</td>";
  69.                             echo"<td align=\"center\"><font face=\"calibri\" color=\"white\">";
  70.                             echo"Stok</td>";
  71.                             echo"<td align=\"center\"><font face=\"calibri\" color=\"white\">";
  72.                             echo"Qty</td>";
  73.                         echo"</tr>";
  74.  
  75.                     $nomor = 0;
  76.  
  77.  
  78.                     foreach($_POST['produk'] as $id){
  79.  
  80.                         $conn = mysql_connect("localhost","root","dancing01")or
  81.                             die(mysql_error()."Cannot connect to server");
  82.  
  83.                         $data = mysql_select_db("warung", $conn)or
  84.                             die(mysql_error()."Cannot connect to database");
  85.  
  86.                         $query = "select merk_produk, kategori, harga_jual, jumlah_stok from master_produk " .
  87.                                   "where merk_produk = '$id' ";
  88.                         $hasil = mysql_query($query, $conn)or
  89.                             die(mysql_error()."An error occure in Query SQL <br> Query: $query");
  90.  
  91.                     while($line = mysql_fetch_row($hasil)){
  92.  
  93.                     $nomor++;
  94.  
  95.                     $banyak = $_POST['qty'];
  96.  
  97.                     $merk = $line[0];
  98.                     $kategori = $line[1];
  99.                     $harga_jual = $line[2];
  100.                     $jumlah_stok = $line[3];
  101.  
  102.                     echo"<tr bgcolor=\"iceblue\">";
  103.                     echo"<td align=\"center\"><font face=\"calibri\" color=\"white\"> $nomor </td>";
  104.                     echo"<td><input type=\"text\" size=\"35%\" name=\"merk\" value=\"$merk\" disabled=\"disabled\"></td>";
  105.                     echo"<td><input type=\"text\" size=\"15%\" name=\"kategori\" value=\"$kategori\" disabled=\"disabled\"></td>";
  106.                     echo"<td><input type=\"text\" size=\"15%\" name=\"harga\" value=\"$harga_jual\"disabled=\"disabled\"></td>";
  107.                     echo"<td><input type=\"text\" size=\"2%\" name=\"stok\" value=\"$jumlah_stok\"disabled=\"disabled\"></td>";
  108.                     echo"<td><input type=\"text\" size=\"2%\" name=\"qty\" value=\"$banyak\" disabled=\"disabled\"></td>";
  109.                     echo"</tr>";
  110.                 }
  111.  
  112.             }
  113.                 echo"<tr bgcolor=\"iceblue\">";
  114.                     echo"<td colspan=\"8\" align=\"right\"><font face=\"calibri\" color=\"white\">Total Harga";
  115.                     echo"<input type=\"textbox\" name=\"total\" disabled=\"disabled\"></td>";
  116.                 echo"</tr>";
  117.                 echo"<tr bgcolor=\"iceblue\">";
  118.                     echo"<td colspan=\"8\" align=\"right\"><input type=\"submit\" name=\"bayar\" value=\"Bayar\"></td>";
  119.                 echo"</tr>";
  120.             echo"</table>";
  121.         }
  122. ?>
  123.  
  124. </body>
  125.  
  126. </html>
Advertisement
Add Comment
Please, Sign In to add comment