Cara menyimpan data dari 2 tabel sekaligus

Bagaimana ya caranya menyimpan data tabel mysql, saya punya 2 tabel yang berbeda div, tabel pertama itu berisi beberapa komponen dan tabel 2 juga seperti itu. Di php my admin kedua tabel tersebut memiliki database nya masing masing, tetapi saat saya jalankan fungsi simpan hanya data di tabel 2 saja yang masuk di database sedangkan data tabel 1 tidak masuk. tolong pencerahannyaa

ini coding dari file simpan data:

sql1 sampai sql 11 adalah tabel 1 sql12 sampai sql21 adalah tabel 2

<?php
include "config.php";

	$sub_kpi = $_POST['sub_kpi'];
	$waktu = $_POST['waktu'];
	$kuantitatif = $_POST['kuantitatif'];
	$kualitatif = $_POST['kualitatif'];
	$catatan_realisasi = $_POST['catatan_realisasi'];
	$nilai = $_POST ['nilai'];
	$bobot = $_POST['bobot'];
	$nilai_kpi = $_POST['nilai_kpi'];

$sql1 = "INSERT INTO `data_penilaian`(`id`, `kpi`, `sub_kpi`, `waktu`, `kuantitatif`, `kualitatif`, `catatan_realisasi`, `nilai`, `bobot`, `nilai_kpi`) VALUES ('', '', '$sub_kpi', '$waktu', '$kuantitatif', '$kualitatif', '$catatan_realisasi', '$nilai', '$bobot', '$nilai_kpi')";
	$hasil1= mysqli_query($conn,$sql1);

	$sub_kpi1 = $_POST['sub_kpi1'];
	$waktu1 = $_POST['waktu1'];
	$kuantitatif1 = $_POST['kuantitatif1'];
	$kualitatif1 = $_POST['kualitatif1'];
	$catatan_realisasi1 = $_POST['catatan_realisasi1'];
	$nilai1 = $_POST ['nilai1'];
	$bobot1 = $_POST['bobot1'];
	$nilai_kpi1 = $_POST['nilai_kpi1'];


$sql2 = "INSERT INTO `penilaian`(`id`, `kpi1`, `sub_kpi1`, `waktu1`, `kuantitatif1`, `kualitatif1`, `catatan_realisasi1`, `nilai1`, `bobot1`, `nilai_kpi1`) VALUES ('', '', '$sub_kpi1', '$waktu1', '$kuantitatif1', '$kualitatif1', '$catatan_realisasi1', '$nilai1', '$bobot1', '$nilai_kpi1')";
	$hasil2= mysqli_query($conn,$sql2);

	$sub_kpi3 = $_POST['sub_kpi3'];
	$waktu3 = $_POST['waktu3'];
	$kuantitatif3 = $_POST['kuantitatif3'];
	$kualitatif3 = $_POST['kualitatif3'];
	$catatan_realisasi3 = $_POST['catatan_realisasi3'];
	$nilai3 = $_POST ['nilai3'];
	$bobot3 = $_POST['bobot3'];
	$nilai_kpi3 = $_POST['nilai_kpi3'];


$sql3 = "INSERT INTO `penilaian 3`(`id`, `kpi3`, `sub_kpi3`, `waktu3`, `kuantitatif3`, `kualitatif3`, `catatan_realisasi3`, `nilai3`, `bobot3`, `nilai_kpi3`) VALUES ('', '', '$sub_kpi3', '$waktu3', '$kuantitatif3', '$kualitatif3', '$catatan_realisasi3', '$nilai3', '$bobot3', '$nilai_kpi3')";
	$hasil3= mysqli_query($conn,$sql3);

$sub_kpi4 = $_POST['sub_kpi4'];
	$waktu4 = $_POST['waktu4'];
	$kuantitatif4 = $_POST['kuantitatif4'];
	$kualitatif4 = $_POST['kualitatif4'];
	$catatan_realisasi4 = $_POST['catatan_realisasi4'];
	$nilai4 = $_POST ['nilai4'];
	$bobot4 = $_POST['bobot4'];
	$nilai_kpi4 = $_POST['nilai_kpi4'];


$sql4 = "INSERT INTO `penilaian 4`(`id`, `kpi4`, `sub_kpi4`, `waktu4`, `kuantitatif4`, `kualitatif4`, `catatan_realisasi4`, `nilai4`, `bobot4`, `nilai_kpi4`) VALUES ('', '', '$sub_kpi4', '$waktu4', '$kuantitatif4', '$kualitatif4', '$catatan_realisasi4', '$nilai4', '$bobot4', '$nilai_kpi4')";
	$hasil4= mysqli_query($conn,$sql4);

	$sub_kpi5 = $_POST['sub_kpi5'];
	$waktu5 = $_POST['waktu5'];
	$kuantitatif5 = $_POST['kuantitatif5'];
	$kualitatif5 = $_POST['kualitatif5'];
	$catatan_realisasi5 = $_POST['catatan_realisasi5'];
	$nilai5 = $_POST ['nilai5'];
	$bobot5 = $_POST['bobot5'];
	$nilai_kpi5 = $_POST['nilai_kpi5'];


$sql5 = "INSERT INTO `penilaian 5`(`id`, `kpi5`, `sub_kpi5`, `waktu5`, `kuantitatif5`, `kualitatif5`, `catatan_realisasi5`, `nilai5`, `bobot5`, `nilai_kpi5`) VALUES ('', '', '$sub_kpi5', '$waktu5', '$kuantitatif5', '$kualitatif5', '$catatan_realisasi5', '$nilai5', '$bobot5', '$nilai_kpi5')";
	$hasil5= mysqli_query($conn,$sql5);

	$sub_kpi6 = $_POST['sub_kpi6'];
	$waktu6 = $_POST['waktu6'];
	$kuantitatif6 = $_POST['kuantitatif6'];
	$kualitatif6 = $_POST['kualitatif6'];
	$catatan_realisasi6 = $_POST['catatan_realisasi6'];
	$nilai6 = $_POST ['nilai6'];
	$bobot6 = $_POST['bobot6'];
	$nilai_kpi6 = $_POST['nilai_kpi6'];


$sql6 = "INSERT INTO `penilaian 6`(`id`, `kpi6`, `sub_kpi6`, `waktu6`, `kuantitatif6`, `kualitatif6`, `catatan_realisasi6`, `nilai6`, `bobot6`, `nilai_kpi6`) VALUES ('', '', '$sub_kpi6', '$waktu6', '$kuantitatif6', '$kualitatif6', '$catatan_realisasi6', '$nilai6', '$bobot6', '$nilai_kpi6')";
	$hasil6= mysqli_query($conn,$sql6);

	$sub_kpi7 = $_POST['sub_kpi7'];
	$waktu7 = $_POST['waktu7'];
	$kuantitatif7 = $_POST['kuantitatif7'];
	$kualitatif7 = $_POST['kualitatif7'];
	$catatan_realisasi7 = $_POST['catatan_realisasi7'];
	$nilai7 = $_POST ['nilai7'];
	$bobot7 = $_POST['bobot7'];
	$nilai_kpi7 = $_POST['nilai_kpi7'];


$sql7 = "INSERT INTO `penilaian 7`(`id`, `kpi7`, `sub_kpi7`, `waktu7`, `kuantitatif7`, `kualitatif7`, `catatan_realisasi7`, `nilai7`, `bobot7`, `nilai_kpi7`) VALUES ('', '', '$sub_kpi7', '$waktu7', '$kuantitatif7', '$kualitatif7', '$catatan_realisasi7', '$nilai7', '$bobot7', '$nilai_kpi7')";
	$hasil7= mysqli_query($conn,$sql7);

	$sub_kpi8 = $_POST['sub_kpi8'];
	$waktu8 = $_POST['waktu8'];
	$kuantitatif8 = $_POST['kuantitatif8'];
	$kualitatif8 = $_POST['kualitatif8'];
	$catatan_realisasi8 = $_POST['catatan_realisasi8'];
	$nilai8 = $_POST ['nilai8'];
	$bobot8 = $_POST['bobot8'];
	$nilai_kpi8 = $_POST['nilai_kpi8'];


$sql8 = "INSERT INTO `penilaian 8`(`id`, `kpi8`, `sub_kpi8`, `waktu8`, `kuantitatif8`, `kualitatif8`, `catatan_realisasi8`, `nilai8`, `bobot8`, `nilai_kpi8`) VALUES ('', '', '$sub_kpi8', '$waktu8', '$kuantitatif8', '$kualitatif8', '$catatan_realisasi8', '$nilai8', '$bobot8', '$nilai_kpi8')";
	$hasil8= mysqli_query($conn,$sql8);

	$sub_kpi9 = $_POST['sub_kpi9'];
	$waktu9 = $_POST['waktu9'];
	$kuantitatif9 = $_POST['kuantitatif9'];
	$kualitatif9 = $_POST['kualitatif9'];
	$catatan_realisasi9 = $_POST['catatan_realisasi9'];
	$nilai9 = $_POST ['nilai9'];
	$bobot9 = $_POST['bobot9'];
	$nilai_kpi9 = $_POST['nilai_kpi9'];


$sql9 = "INSERT INTO `penilaian 9`(`id`, `kpi9`, `sub_kpi9`, `waktu9`, `kuantitatif9`, `kualitatif9`, `catatan_realisasi9`, `nilai9`, `bobot9`, `nilai_kpi9`) VALUES ('', '', '$sub_kpi9', '$waktu9', '$kuantitatif9', '$kualitatif9', '$catatan_realisasi9', '$nilai9', '$bobot9', '$nilai_kpi9')";
	$hasil9= mysqli_query($conn,$sql9);

	$sub_kpi10 = $_POST['sub_kpi10'];
	$waktu10 = $_POST['waktu10'];
	$kuantitatif10 = $_POST['kuantitatif10'];
	$kualitatif10 = $_POST['kualitatif10'];
	$catatan_realisasi10 = $_POST['catatan_realisasi10'];
	$nilai10 = $_POST ['nilai10'];
	$bobot10 = $_POST['bobot10'];
	$nilai_kpi10 = $_POST['nilai_kpi10'];


$sql10 = "INSERT INTO `penilaian 10`(`id`, `kpi10`, `sub_kpi10`, `waktu10`, `kuantitatif10`, `kualitatif10`, `catatan_realisasi10`, `nilai10`, `bobot10`, `nilai_kpi10`) VALUES ('', '', '$sub_kpi10', '$waktu10', '$kuantitatif10', '$kualitatif10', '$catatan_realisasi10', '$nilai10', '$bobot10', '$nilai_kpi10')";
	$hasil10= mysqli_query($conn,$sql10);

	$sub_kpi11 = $_POST['sub_kpi11'];
	$waktu11 = $_POST['waktu11'];
	$kuantitatif11 = $_POST['kuantitatif11'];
	$kualitatif11 = $_POST['kualitatif11'];
	$catatan_realisasi11 = $_POST['catatan_realisasi11'];
	$nilai11 = $_POST ['nilai11'];
	$bobot11 = $_POST['bobot11'];
	$nilai_kpi11 = $_POST['nilai_kpi11'];


$sql11 = "INSERT INTO `penilaian 11`(`id`, `kpi11`, `sub_kpi11`, `waktu11`, `kuantitatif11`, `kualitatif11`, `catatan_realisasi11`, `nilai11`, `bobot11`, `nilai_kpi11`) VALUES ('', '', '$sub_kpi11', '$waktu11', '$kuantitatif11', '$kualitatif11', '$catatan_realisasi11', '$nilai11', '$bobot11', '$nilai_kpi11')";
	$hasil11= mysqli_query($conn,$sql11);


	$bukti_implementasi = $_POST['bukti_implementasi'];
	$nilai_huruf = $_POST['nilai_huruf'];

$sql12 = "INSERT INTO `nilai_huruf`(`id_nilai_huruf`, `nilai_nilai`, `perilaku_utama`, `perilaku_diharapkan`, `bukti_implementasi`, `nilai_huruf`) VALUES ('', '', '', '' , '$bukti_implementasi', '$nilai_huruf')";
	$hasil12= mysqli_query($conn,$sql12);

	$bukti_implementasi2 = $_POST['bukti_implementasi2'];
	$nilai_huruf2 = $_POST['nilai_huruf2'];

$sql13 = "INSERT INTO `nilai_huruf2`(`id_nilai_huruf2`, `nilai_nilai2`, `perilaku_utama2`, `perilaku_diharapkan2`, `bukti_implementasi2`, `nilai_huruf2`) VALUES ('', '', '', '' , '$bukti_implementasi2', '$nilai_huruf2')";
	$hasil13= mysqli_query($conn,$sql13);

	$bukti_implementasi3 = $_POST['bukti_implementasi3'];
	$nilai_huruf3 = $_POST['nilai_huruf3'];

$sql14 = "INSERT INTO `nilai_huruf3`(`id_nilai_huruf3`, `nilai_nilai3`, `perilaku_utama3`, `perilaku_diharapkan3`, `bukti_implementasi3`, `nilai_huruf3`) VALUES ('', '', '', '' , '$bukti_implementasi3', '$nilai_huruf3')";
	$hasil14= mysqli_query($conn,$sql14);

	$bukti_implementasi4 = $_POST['bukti_implementasi4'];
	$nilai_huruf4 = $_POST['nilai_huruf4'];

$sql15 = "INSERT INTO `nilai_huruf4`(`id_nilai_huruf4`, `nilai_nilai4`, `perilaku_utama4`, `perilaku_diharapkan4`, `bukti_implementasi4`, `nilai_huruf4`) VALUES ('', '', '', '', '$bukti_implementasi4', '$nilai_huruf4')";
	$hasil15 = mysqli_query($conn,$sql15);

	$bukti_implementasi5 = $_POST['bukti_implementasi5'];
	$nilai_huruf5 = $_POST['nilai_huruf5'];

$sql16 = "INSERT INTO `nilai_huruf5`(`id_nilai_huruf5`, `nilai_nilai5`, `perilaku_utama5`, `perilaku_diharapkan5`, `bukti_implementasi5`, `nilai_huruf5`) VALUES ('', '', '', '' , '$bukti_implementasi5', '$nilai_huruf5')";
	$hasil16= mysqli_query($conn,$sql16);

	$bukti_implementasi6 = $_POST['bukti_implementasi6'];
	$nilai_huruf6 = $_POST['nilai_huruf6'];

$sql17 = "INSERT INTO `nilai_huruf6`(`id_nilai_huruf6`, `nilai_nilai6`, `perilaku_utama6`, `perilaku_diharapkan6`, `bukti_implementasi6`, `nilai_huruf6`) VALUES ('', '', '', '' , '$bukti_implementasi6', '$nilai_huruf6')";
	$hasil17= mysqli_query($conn,$sql17);

	$bukti_implementasi7 = $_POST['bukti_implementasi7'];	
	$nilai_huruf7 = $_POST['nilai_huruf7'];

$sql18 = "INSERT INTO `nilai_huruf7`(`id_nilai_huruf7`, `nilai_nilai7`, `perilaku_utama7`, `perilaku_diharapkan7`, `bukti_implementasi7`, `nilai_huruf7`) VALUES ('', '', '', '' , '$bukti_implementasi7', '$nilai_huruf7')";
	$hasil18= mysqli_query($conn,$sql18);

	$bukti_implementasi8 = $_POST['bukti_implementasi8'];
	$nilai_huruf8 = $_POST['nilai_huruf8'];

$sql19 = "INSERT INTO `nilai_huruf8`(`id_nilai_huruf8`, `nilai_nilai8`, `perilaku_utama8`, `perilaku_diharapkan8`, `bukti_implementasi8`, `nilai_huruf8`) VALUES ('', '', '', '' , '$bukti_implementasi8', '$nilai_huruf8')";
	$hasil19= mysqli_query($conn,$sql19);

	$bukti_implementasi9 = $_POST['bukti_implementasi9'];
	$nilai_huruf9 = $_POST['nilai_huruf9'];

$sql20 = "INSERT INTO `nilai_huruf9`(`id_nilai_huruf9`, `nilai_nilai9`, `perilaku_utama9`, `perilaku_diharapkan9`, `bukti_implementasi9`, `nilai_huruf9`) VALUES ('', '', '', '' , '$bukti_implementasi9', '$nilai_huruf9')";
	$hasil20= mysqli_query($conn,$sql20);

	$bukti_implementasi10 = $_POST['bukti_implementasi10'];
	$nilai_huruf10 = $_POST['nilai_huruf10'];

$sql21 = "INSERT INTO `nilai_huruf10`(`id_nilai_huruf10`, `nilai_nilai10`, `perilaku_utama10`, `perilaku_diharapkan10`, `bukti_implementasi10`, `nilai_huruf10`) VALUES ('', '', '', '' , '$bukti_implementasi10', '$nilai_huruf10')";
	$hasil21= mysqli_query($conn,$sql21);



	if ($hasil1) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
	}

	if ($hasil2) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
	}
	if ($hasil3) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}

	if ($hasil4) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}

	if ($hasil5) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}
	if ($hasil6) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}
	if ($hasil7) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}

	if ($hasil8) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}

	if ($hasil9) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}

	if ($hasil10) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
}
	if ($hasil11) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 

	if ($hasil12) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 

	if ($hasil13) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 

if ($hasil14) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 
if ($hasil15) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 
if ($hasil16) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 
if ($hasil17) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 
if ($hasil18) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 
if ($hasil19) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 
if ($hasil20) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 
if ($hasil21) {
	echo "<script>
	alert('Berhasil insert data');
	
	</script>";
} 

	else {
	echo "<script>
	alert('Gagal insert data');

	</script>";
	}
?>

avatar sd_clouds
@sd_clouds

6 Kontribusi 0 Poin

Diperbarui 1 bulan yang lalu

Tanggapan

mengapa banyak sekali tabel yang struktur datanya sama semua?

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban