Advertisement
cdsatrian

nilai per semester

Jan 2nd, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.73 KB | None | 0 0
  1. <?php
  2. /************************
  3. created by   : CAHYA DSN
  4. created date : 2013-01-02
  5. status       : not tested
  6. *************************/
  7. //collecting data from previous POST
  8. $nis        =isset($_POST['isi'])?$_POST['isi']:'';
  9. $nip        =isset($_POST['nip'])?$_POST['nip']:'';
  10. $isi        =isset($_POST['namakepala'])?$_POST['namakepala']:'';
  11. $periode    =isset($_POST['thn'])?$_POST['thn']:'';
  12. $tahunajaran=isset($_POST['tahunajaran'])?$_POST['tahunajaran']:'';
  13. ?>
  14. <!DOCTYPE html>
  15. <html>
  16. <head>
  17. <title>Data Nilai</title>
  18. <style type="text/css">
  19. body,table {font-family:arial,verdana, sans-serif; font-size:10pt;}
  20. .left {float:left;}
  21. .right {float:right;}
  22. .clear {clear:both;}
  23. .label {width:150px;font-weight:normal;}
  24. .colon {width:40px;}
  25. .data {width:150px;font-weight:bold;}
  26. .header_sekolah {font-size:14pt;width:100%;}
  27. .header_judul {font-size:18pt;width:100%;}
  28. .container {width:100%;}
  29. .dark {background-color:#eee;}
  30. .light {background-color:#fff;}
  31. </style>
  32. </head>
  33. <body>
  34. <?php
  35. if($nis){
  36.   include("../library/koneksi.php");
  37. ?>
  38. <div class="header_sekolah">
  39. MADRASAH TSANAWIAH NEGERI SUBANG ANAK<br />
  40. KABUPATEN TANAH DATAR<br />
  41. JL. RAYA PADANG PANJANG - SOLOK
  42. </div>
  43. <div class="header_judul">DATA NILAI</div>
  44. <?php
  45. $sql="SELECT namasiswa, kelas FROM siswa WHERE nis = '".$nis."'";
  46. $query = mysql_query($sql)or die ("Query failed with error: ".mysql_error());
  47. $data = mysql_fetch_array($query);
  48. ?>
  49. <div class="container">
  50.   <div class="label left">NISN</div>
  51.   <div class="colon left">:</div>
  52.   <div class="data left"><?php echo $nis;?></div>
  53.   <div class="label right">Tahun Ajaran :</div>
  54.   <div class="data right"><?php echo $tahunajaran; ?></div>
  55.   <div class="clear"></div>
  56.   <div class="label left">Nama Siswa</div>
  57.   <div class="colon left">:</div>
  58.   <div class="data left"><?php echo $data['namasiswa'];?></div>
  59.   <div class="clear"></div>
  60.   <div class="label left">Kelas</div>
  61.   <div class="colon left">:</div>
  62.   <div class="data left"><?php echo $data['kelas'];?></div>
  63.   <div class="clear"></div>
  64.   <div class="datagrid">
  65.   <table width="100%" border="0">
  66. <?php
  67.   $sql="SELECT n.nis, n.kodematapelajaran, n.nilaiMID, n.nilaiUAS, mp.namamatapelajaran, mp.semester
  68.        FROM nilai n,matapelajaran mp
  69.        WHERE n.kodematapelajaran=mp.kodematapelajaran
  70.        AND n.nis = '".$nis."'
  71.        ORDER BY mp.semester";
  72.   $query = mysql_query($sql)or die ("Query failed with error: ".mysql_error());
  73.   if(mysql_num_rows($query)){
  74.     $i=0;
  75.     $semester=0;
  76.     while ($data = mysql_fetch_array($query)){
  77.       if($semester!=$data['semester']){
  78.         $semester=$data['semester'];
  79.         echo "<tr><th colspan=\"5\"> SEMESTER $semester</th></tr>\n"
  80.             ."<tr>\n"
  81.             ."<th>KODE MATAPELAJARAN</th>\n"
  82.             ."<th>NAMA MATAPELAJARAN</th>\n"
  83.             ."<th>SEMESTER</th>\n"
  84.             ."<th>NILAI MID</th>\n"
  85.             ."<th>NILAI UAS</th>\n"
  86.             ."</tr>\n";
  87.       }
  88. ?>
  89. <tr class="<?php echo $i%2==0?"dark":"light";?>">
  90.   <td><?php echo $data['kodematapelajaran'];?></td>
  91.   <td><?php echo $data['namamatapelajaran'];?></td>
  92.   <td><?php echo $data['semester'];?></td>
  93.   <td><?php echo $data['nilaiMID'];?></td>
  94.   <td><?php echo $data['nilaiUAS'];?></td>
  95. </tr>
  96. <?php
  97.     }// end while
  98.     echo "<tr>\n"
  99.         ."<td colspan=\"5\">\n"
  100.         ."<a href=\"semua.php?page=cetak&nis=".$nis."&isi=".$isi."&nip=".$nip."&tahunajaran=".$tahunajaran."\" target=\"_blank\">\n"
  101.         ."<img src=\"images/Printer1.png\" title=\"PRINT NILAI\"/>\n"
  102.         ."</a></td></tr>\n";
  103.   }else{
  104.     echo "<tr><td colspan=\"5\">Data Not Found</td></tr>\n";
  105.   }
  106. ?>
  107. </table>
  108. </div> <!-- container -->
  109. <?php
  110. } else{
  111.   echo "please provide correct 'NIS' number";
  112. }
  113. ?>
  114. </body>
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement