Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pre>
- <?php
- // contoh data-nya
- $idnilai='201301';
- $nis='201003123';
- $lokal=3;
- $agm=8.7;
- $bin=7.4;
- $eng=8.5;
- $bas=7.9;
- $bar=8.2;
- $tgl_agm='04/01/2013';
- $tgl_bin='05/01/2013';
- $tgl_eng='06/01/2013';
- $tgl_bas='07/01/2013';
- $tgl_bar='08/01/2013';
- //-- generate query-nya
- $mps=array('AGM','BIN','ENG','BAS','BAR');
- $qry=$qry2='';
- foreach($mps as $mp){
- //-- model 1
- $qry.="INSERT INTO tb_nilai_mid(mid_id,user_id,mid_lokal,mid_nilai,mid_mp,mid_tgl_ujian) "
- ."VALUES('".$idnilai."$mp','$nis','$lokal','$bin','".${strtolower($mp)}."','".${"tgl_".strtolower($mp)}."');\n";
- //-- model 2
- $qry2.=(empty($qry2)?"INSERT INTO tb_nilai_mid(mid_id,user_id,mid_lokal,mid_nilai,mid_mp,mid_tgl_ujian) VALUES":",")
- ."('".$idnilai."$mp','$nis','$lokal','$bin','".${strtolower($mp)}."','".${"tgl_".strtolower($mp)}."')\n";
- }
- //-- hasil generate query-nya
- echo $qry."\natau\n\n".$qry2.";";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement