emprit

checkbox

Mar 26th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.01 KB | None | 0 0
  1. <center><h3>Form Input SPP Perkelas</h3></center>
  2. <form method="POST" action="./dXBkYXRlX2lucHV0X3NwcA.htm" >
  3.     <table class="table table-hover">
  4.     <?php
  5.         //bulan
  6.         $bulangasal = array("juli","agustus","september","oktober","nopember","desember");
  7.         $bulangenap = array("januari","februari","maret","april","mei","juni");
  8.  
  9.         //select semester
  10.         $semes = mysql_fetch_array(mysql_query("SELECT kode, ket_smstr FROM semester WHERE aktif='aktif'"))or die(mysql_error());
  11.         $kode   = $semes['kode'];
  12.         $status = $semes['ket_smstr'];
  13.  
  14.         //mencaritahu gasal atau genap
  15.         $s      = explode($status, " ");
  16.         $g      = $s[0];
  17.     ?>
  18.         <thead>
  19.             <tr>
  20.                 <th>NIS</th>
  21.                 <th>Nama</th>
  22.                 <?php
  23.                 //buat bulan
  24.                 if($g == 'Gasal'){
  25.                     for($n=0; $n<6; $n++){
  26.                         echo "<th>".ucfirst($bulangasal[$n])."</th>";
  27.                     }
  28.                 }else{
  29.                     for($n=0; $n<6; $n++){
  30.                         echo "<th>".ucfirst($bulangenap[$n])."</th>";
  31.                     }
  32.                 }
  33.                 ?>
  34.             </tr>
  35.         </thead>
  36.         <tbody>
  37.            
  38.             <?php
  39.                 $siswa = mysql_query("SELECT nis, nama FROM student WHERE id_kelas='".$_POST['kelas']."'");
  40.                 while ($s = mysql_fetch_array($siswa)) {
  41.  
  42.                 echo "<tr>
  43.                         <td>".$s['nis']."</td>
  44.                         <td>".$s['nama']."</td>";
  45.  
  46.                         for($a=0; $a<6; $a++){
  47.  
  48.                             //query untuk valuenya
  49.                             $h = mysql_num_rows(mysql_query("SELECT * FROM keu_$kode WHERE nis='".$s['nis']."'"));
  50.  
  51.                             if($h = '0'){
  52.  
  53.                                 $value = '0';
  54.                                 $cek   = 'checked';
  55.  
  56.                             }else{
  57.                                
  58.                                 $keu = mysql_fetch_array(mysql_query("SELECT * FROM keu_$kode WHERE nis='".$s['nis']."'"))or die(mysql_error());
  59.                                
  60.                                 //gasal
  61.                                 if($g == 'Gasal'){
  62.  
  63.                                     for($n=0; $n<6; $n++){
  64.                                         if ($keu[$bulangasal[$n]] == '1') {
  65.                                             $value = '1';
  66.                                             $cek   = 'checked';
  67.                                         }else{
  68.                                             $value = '0';
  69.                                             $cek   = '';
  70.                                         }
  71.                                     }
  72.  
  73.                                 }else{
  74.  
  75.                                     for($n=0; $n<6; $n++){
  76.                                         if ($keu[$bulangenap[$n]] == '1') {
  77.                                             $value = '1';
  78.                                             $cek   = 'checked';
  79.                                         }else{
  80.                                             $value = '0';
  81.                                             $cek   = '';
  82.                                         }
  83.                                     }
  84.  
  85.                                 }
  86.                                
  87.  
  88.                             }
  89.  
  90.                             echo "<td>
  91.                                      <label class='checkbox'>
  92.                                         <input type='checkbox' name='input[]' value='$value' $cek>
  93.                                      </label>
  94.                                   </td>";
  95.                         }
  96.                 echo "</tr>";
  97.                 }
  98.             ?>
  99.         </tbody>
  100.     </table>
  101.     <center><button class="btn"><i class="icon-info-sign"></i> Input SPP</button></center>
  102. </form>
  103.  
  104. ------------------------------------------------------------------------------------------------------------------------
  105. <form method="POST" action="./dXBkYXRlX2lucHV0X3NwcA.htm" >
  106.     <table class="table table-hover">
  107.             <thead>
  108.             <tr>
  109.                 <th>NIS</th>
  110.                 <th>Nama</th>
  111.                 <th>Januari</th><th>Februari</th><th>Maret</th><th>April</th><th>Mei</th><th>Juni</th>          </tr>
  112.         </thead>
  113.         <tbody>
  114.            
  115.             <tr>
  116.                         <td>1234</td>
  117.                         <td>Biancha</td>
Advertisement
Add Comment
Please, Sign In to add comment