Advertisement
cdsatrian

insert.php

Jun 28th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2. error_reporting(-1);
  3. mysql_connect("localhost", "root", "root");
  4. mysql_select_db("pln");
  5. $tim     = $_POST['C_TIM'];
  6. $id_msk  = $_POST['ID_MSK'];
  7. $kwh     = $_POST['NO_KWH'];
  8. $tgl     = $_POST['TGL_MSK'];
  9. $merk    = $_POST['MERK'];
  10. $kd_brg  = $_POST['KD_BRG'];
  11. $jml_msk = $_POST['JML_MSK'];
  12. $jumlah_data=count($kd_brg);
  13. for ($i=0; $i<$jumlah_data; $i++){
  14.   if ((!empty($kd_brg[$i])) && (!empty($jml_msk[$i]))){
  15.     $query   = "INSERT INTO t_msk(ID_MSK, KD_BRG, TGL_MSK) VALUES ('$no', '".$kd_brg[$i]."', '$tgl')";
  16.     $hasil   = mysql_query($query)  or die(mysql_error());
  17.     $qry   = "INSERT INTO td_msk(NO_MSK, NO_KWH, C_TIM, ID_MSK, JML_MSK) VALUES ('', '$kwh', '$tim', '$id_msk','".$jml_msk[$i]."')";
  18.     $has   = mysql_query($qry) or die(mysql_error());
  19.     $kwh   = "INSERT INTO t_meter VALUES ('$kwh', '0', '0', '$merk')";
  20.     $hasq   = mysql_query($kwh)  or die(mysql_error());
  21.     if ($hasil&&$has&&$hasq) {
  22.       echo "Input data sukses<br>";
  23.     } else {
  24.       echo "Input data gagal<br>";
  25.     }
  26.   }
  27. }
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement