Script Memasukkan Data untuk 4 tabel sekaligus

$cek="INSERT INTO bunga(kd_bunga,nama,harga,gambar,deskripsi)
Values('$kd_bunga','$nama','$harga','".$kd_bunga.".jpg','$deskripsi')";
$input=mysql_query($cek);
copy($gambar,"../bunga/"."$kd_bunga.jpg");

$tags=$_POST[tags];
$jm=count($tags);
for ($i=0; $i<$jm;$i++){
mysql_query ("insert into by_tag (kode, tags, nama, harga, gambar) values ('$kd_bunga','$tags[$i]', '$nama','$harga','$kd_bunga.jpg')");}

$rec=$_POST[rec];
$jml=count($rec);
for ($j=0; $j<$jml;$j++){
mysql_query ("insert into by_rec (kode, rec, nama, harga, gambar) values ('$kd_bunga','$rec[$j]', '$nama', '$harga','$kd_bunga.jpg')");}

$jenis=$_POST[jenis];
$jum=count($jenis);
for ($k=0; $k<$jum;$k++){
mysql_query ("insert into by_jenis (kode, jenis, nama, harga, gambar) values ('$kd_bunga','$jenis[$k]', '$nama', '$harga','$kd_bunga.jpg')");}

4 thoughts on “Script Memasukkan Data untuk 4 tabel sekaligus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s