Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form14")) {
- $data = $_POST['jumlah_tps'];
- $id = autonumber("tps", "id", 1, "");
- $code_region = 1;
- $name_region = $_POST['name_region'];
- $code_prov = $_POST['code_prov'];
- $row1 = mysql_fetch_assoc(mysql_query("select * from master_region where code_region='$code_prov'"));
- $name_prov = $row1['name_region'];
- $code_kab = $_POST['code_kab'];
- $row2 = mysql_fetch_assoc(mysql_query("select * from master_region where code_region='$code_kab'"));
- $name_kab = $row2['name_region'];
- $code_kec = $_POST['code_kec'];
- $row3 = mysql_fetch_assoc(mysql_query("select * from master_region where code_region='$code_kec'"));
- $name_kec = $row3['name_region'];
- $code_kel = $_POST['code_kel'];
- $row4 = mysql_fetch_assoc(mysql_query("select * from master_region where code_region='$code_kel'"));
- $name_kel = $row4['name_region'];
- $role = "CHECKER";
- mysql_select_db($name_database, $database);
- for($i=0;$i<$data;$i++) {
- $code_tps = autostring("tps","code_tps",$code_kel,4,$code_kel.".");
- $name_tps = substr($code_tps,-4);
- $password = $code_tps;
- $code_tps2 = $code_tps.".".sprintf("%04s",$i);
- $insertSQL = sprintf("INSERT HIGH_PRIORITY INTO tps (id, code_region, name_region, code_prov, name_prov, code_kab, name_kab, code_kec, name_kec, code_kel, name_kel, code_tps, name_tps, password, role) VALUES (%s, %s, %s,%s, %s, %s,%s, %s, %s,%s, %s, %s,%s, %s, %s)",
- GetSQLValueString($id, "text"),
- GetSQLValueString($code_region, "text"),
- GetSQLValueString($name_region, "text"),
- GetSQLValueString($code_prov, "text"),
- GetSQLValueString($name_prov, "text"),
- GetSQLValueString($code_kab, "text"),
- GetSQLValueString($name_kab, "text"),
- GetSQLValueString($code_kec, "text"),
- GetSQLValueString($name_kec, "text"),
- GetSQLValueString($code_kel, "text"),
- GetSQLValueString($name_kel, "text"),
- GetSQLValueString($code_tps2, "text"),
- GetSQLValueString($name_tps, "text"),
- GetSQLValueString($password, "text"),
- GetSQLValueString($role, "text"));
- $Result1 = mysql_query($insertSQL, $database) or die("sql:$insertSQL|".mysql_error());
- }
- echo '<script>alert("Data berhasil dibuat"); location.href="tps"</script>';
- }
Add Comment
Please, Sign In to add comment