Advertisement
cdsatrian

seksi.php r1

Dec 8th, 2013
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. //FORM
  2. <?php
  3.   $opts='';
  4.   $querys = mysql_query("SELECT id_peg,nama_peg
  5.                         FROM tb_pegawai
  6.                         WHERE jabatan_peg='Guru'
  7.                         ORDER BY nama_peg");
  8.   while ($rows = mysql_fetch_array($querys)){
  9.     $opts.="<option value='$rows[id_peg]'>".$rows['nama_peg']."</option>\n";
  10.   }
  11.   $query = mysql_query("SELECT id_mapel,nama_mapel
  12.                        FROM tb_mapel ");
  13.   while ($row1 = mysql_fetch_array($query))
  14.   {
  15.     ?>
  16.     <tr>
  17.       <td>
  18.         <input type="checkbox"
  19.                name="id_mapel[]"
  20.                class="id_mapel"
  21.                value="<?php echo $row1['id_mapel']; ?>" />
  22.         &nbsp;<?php echo $row1['nama_mapel']; ?>
  23.       </td>          
  24.       <td>
  25.         <select class="span7"
  26.                 name="guru[<?php echo $row1['id_mapel']; ?>]">
  27.           <?php echo $opts;?>
  28.         </select>
  29.       </td>
  30.     </tr>
  31.     <input type="hidden" name="kelas" value="<?php echo $kelas;?>" />
  32.     <?php
  33.   }
  34. ?>
  35.  
  36. //PROSES
  37. <?php
  38.   $kelas= mysql_real_escape_string($_POST['kelas']);
  39.   $thn  = date('Y');
  40.   $thn2 = $thn+1;                      
  41.   while(list($key1, $value1) = each($_POST['id_mapel']))
  42.   {
  43.     $kode_seksi = buatkode("tb_seksi", "SK");
  44.     $value2=$_POST['guru'][$value1];
  45.     $sql = "INSERT INTO tb_seksi VALUES
  46.            ('$kode_seksi', '$value1', '$value2','$kelas','$thn-$thn2')";
  47.     $res = mysql_query($sql) or die(mysql_error()."<br>".$sql);
  48.   }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement