Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--begin of combo.php file
- <html>
- <head>
- <title></title>
- <script src="../datetimepicker_css.js"></script>
- </head>
- <body>
- <hr />
- <h3>.: Input Data Barang :.</h3>
- <form method="post" action="combo.php">
- Jumlah Item Barang :
- <input type="text" name="jum">
- <input type="submit" name="submit" value="Submit">
- </form>
- <?
- if($_POST){
- //include '../../koneksi.php';
- $C= mysql_connect("localhost", "root", "root") or die(mysql_error());
- mysql_select_db("pln");
- function select_barang(){
- $select= "<select name='KD_BRG[]' >";
- $query = mysql_query("SELECT a.KD_BRG, a.NM_BRG, b.SATUAN FROM t_brg a, t_satuan b WHERE a.ID_SAT=b.ID_SAT")or die(mysql_error());
- while ($row = mysql_fetch_array($query)) {
- $select.= '<option value="' . $row['KD_BRG'] . '">' . $row['NM_BRG'] . '('.$row['SATUAN'].')</option>';
- }
- $select.="</select> *Pilih dari list disamping";
- return $select;
- }
- $jum = $_POST['jum'];
- $tug=mysql_query("SELECT MAX(CAST(substring(ID_MSK, 4)AS UNSIGNED)) FROM t_msk ");
- $arrData2 = mysql_fetch_row($tug);
- $gabtug = 'TUG'.($arrData2[0] ? ++$arrData2[0] : 1);
- $datanim = $_POST['KD_BRG'];
- $qry = "SELECT a.C_TIM, a.NM_KETUA, a.NM_KASIR, a.NM_ENTRY, a.NM_APP,
- b.NM_BIRO, c.LOKASI FROM t_tim a, t_biro b, t_lokasi c
- WHERE a.C_BIRO=b.C_BIRO AND c.C_LOKASI=b.C_LOKASI
- ORDER BY a.C_TIM ASC";
- $hsl = mysql_query($qry);
- $ary = mysql_fetch_array($hsl);
- ?>
- <form method="post" action="insert.php">
- <h3>.: Data Tim Sarling :. </h3>
- <table width="339" border="0">
- <tr>
- <td width="138">Nama Tim</td>
- <td width="10">:</td>
- <td width="162"><input type="text" name="C_TIM" id="C_TIM" value="<? echo $ary['C_TIM']; ?>" /></td>
- <td width="11"> </td>
- </tr>
- <tr>
- <td>Nama APP</td>
- <td>:</td>
- <td><input type="text" name="NM_APP" id="NM_APP" value="<? echo $ary['NM_APP']; ?>"/></td>
- <td> </td>
- </tr>
- <tr>
- <td>Nama Biro</td>
- <td> </td>
- <td><input type="text" name="NM_BIRO" id="NM_BIRO" value="<? echo $ary['NM_BIRO']; ?>"/></td>
- <td> </td>
- </tr>
- <tr>
- <td>Lokasi</td>
- <td>:</td>
- <td><input type="text" name="LOKASI" id="LOKASI" value="<? echo $ary['LOKASI']; ?>"/></td>
- <td> </td>
- </tr>
- </table>
- <hr />
- <h2>.: INPUT DATA BARANG SEBANYAK <?=$jum;?> :.</h2>
- <table border=0 >
- <tr>
- <td>No Masuk </td>
- <td><input type="text" name="ID_MSK" id="ID_MSK" value="<? echo $gabtug; ?>"></td>
- </tr>
- <tr>
- <td>Tanggal </td>
- <td>
- <input type="text" name="TGL_MSK" id="TGL_MSK" />
- <img src="../images2/cal.gif" alt="" height="18" style="cursor:pointer" onClick="javascript:NewCssCal('TGL_MSK','yyyyMMdd')"/></td>
- </tr>
- <tr>
- <td>Nomor KWH</td>
- <td>
- <input type="text" name="NO_KWH" id="NO_KWH"></td>
- </tr>
- <tr>
- <td>Merek </td>
- <td>
- <input type="text" name="MERK" id="MERK"></td>
- </tr>
- <?php
- for ($i=1; $i<=$n; $i++){
- echo "
- <tr>
- <tr>
- <td>Nama Barang</td>
- <td>".select_barang()."</td>
- </tr>
- <tr>
- <td>Jumlah</td>
- <td><input type='text' name='JML_MSK[]'></td>
- </tr>
- </tr>";
- }
- ?>
- </table>
- </p>
- <input type="hidden" name="jum" value="<? echo $jum;?>" />
- <input type="hidden" name="C_TIM" value="<? echo $ary['C_TIM']; ?>" />
- <input type="submit" name="submit" value="Submit">
- <br></form>
- <?php
- }
- ?>
- <p>
- </p>
- </body>
- </html>
- //--end of combo.php file
- ======
- // -- begin of insert.php file
- <?php
- mysql_connect("localhost", "root", "root");
- mysql_select_db("pln");
- $jumlah_data = $_POST['jum']; // membaca jumlah data
- $tim = $_POST['C_TIM'];
- $no = $_POST['ID_MSK'];
- $kwh = $_POST['NO_KWH'];
- $tgl = $_POST['TGL_MSK'];
- $merk = $_POST['MERK'];
- for ($i=0; $i<$jumlah_data; $i++){
- $kd_brg = $_POST['KD_BRG'];
- $jml_msk = $_POST['JML_MSK'];
- if ((!empty($kd_brg[$i])) && (!empty($jml_msk[$i]))){
- $query = "INSERT INTO t_msk(ID_MSK, KD_BRG, TGL_MSK) VALUES ('$no', '".$kd_brg[$i]."', '$tgl')";
- $qry = "INSERT INTO td_msk(NO_MSK, NO_KWH, C_TIM, ID_MSK, JML_MSK) VALUES ('', '$kwh', '$tim', '$no','".$jml_msk[$i]."')";
- $kwh = "INSERT INTO t_meter VALUES ('$kwh', '0', '0', '$merk')";
- $hasil = mysql_query($query) or die(mysql_error());
- $has = mysql_query($qry) or die(mysql_error());
- $hasq = mysql_query($kwh) or die(mysql_error());
- if ($hasil&&$has&&$hasq) {
- echo "Input data sukses<br>";
- } else {
- echo "Input data gagal<br>";
- }
- }
- }
- ?>
- //--end of insert.php file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement