pitnamaq

rangking siswa

Jan 5th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. <?php
  2.     $id_kelas=$_POST['kelas']; 
  3.     $id_ajaran=$_POST['ajaran'];
  4.     $no=0;
  5.     $a=0;
  6.     $b=0;
  7.     $c=0;
  8.     $v=0;
  9.     $y=0;
  10.     $z=0;
  11.     $f=0;
  12.     $g=0;
  13.     $h=0;
  14.     $p=0;
  15.     $e=0;
  16. ?>
  17. <?php
  18. $sql =" select * from tb_detailkelas
  19.             where id_kelas='$id_kelas' and id_ajaran='$id_ajaran'";
  20.             $hasil = mysql_query($sql) ;//or die ("Kesalahan pada perintah SQL!");
  21.             echo mysql_error();
  22.             while ($data=mysql_fetch_array($hasil)){
  23.         ?>
  24.             <tr>
  25.                 <td><?php   $no; ?> </td>
  26.                 <td><?php   $data['nis']?></td>
  27.                
  28.             </tr>
  29. <?php
  30. $test=$data['nis'];
  31. $no++;
  32. $sql1 =" select * from tb_rapot
  33. where nis='$test' and id_ajaran='$id_ajaran' order by nilai_rapot desc";
  34.     $hasil1 = mysql_query($sql1) ;
  35.  
  36.     echo mysql_error();
  37.     while ($data1=mysql_fetch_array($hasil1)){
  38.     ?>
  39.     <tr>
  40.         <td><?php   $no; ?> </td>
  41.         <td><?php   $data1['nis']?></td>
  42.         <td><?php   $data1['nilai_rapot']?></td>
  43.        
  44.     </tr>
  45.     <?php
  46.             //$e1=$data['nis'];
  47.             $d=$data1['nilai_rapot'];
  48.             //var_dump($d);
  49.             if      ($a=0){$a=$d; $f= $data1['nis'];}
  50.             else if ($b=0){$b=$d; $g= $data1['nis'];}
  51.             else if ($c=0){$c=$d; $h= $data1['nis'];}
  52.             else if ($d>$a and $d>$b and $d>$c ){ $a=$d;  $h= $data1['nis'];}
  53.             else if ($d>$a and $d>$b and $d<$c ){ $b=$d;  $g= $data1['nis'];}
  54.             else if ($d>$a and $d<$b and $d<$c ){ $c=$d;  $f= $data1['nis'];}
  55.         }
  56.        
  57.     }
  58.                        
  59.  
  60. ?>
  61.  
  62.  
  63. <?php
  64. if($a>$b && $a>$c){$y=1;}
  65. else if($b>$c){$v=2;}
  66. else{$z=3;}
  67. ?>
  68. <td>NIS:<?php echo $h; ?> </td><td>rangking :<?php echo $y; ?></td>
  69. <td>NIS:<?php echo $g; ?> </td><td>rangking :<?php echo $v; ?></td>
  70. <td>NIS:<?php echo $f; ?> </td><td>rangking :<?php echo $z; ?></td>
Advertisement
Add Comment
Please, Sign In to add comment