Advertisement
GWibisono

bayar spp

Aug 28th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2. error_reporting(1);
  3. require 'config.php';
  4. $sql="select * from siswa";
  5. $q=$mysqli->query($sql);
  6.     if(!$q)
  7.     {
  8.         die($mysqli->error);
  9.     }
  10. $n=0;
  11. $s='<table>';
  12. while ($row = $q->fetch_assoc())
  13. {
  14.     $s.="\n<tr>";
  15.     $s.="\n\t<td>$row[nis]</td>";
  16.     $s.="\n\t<td>$row[nama]</td>";
  17.     for($i=7;$i<=12;$i++)
  18.     {
  19.         $i2=spp($row[nis],$i);
  20.         $s.="\n\t<td>Rp  ".number_format($i2)."</td>";
  21.         $aTot[$i]+=$i2;
  22.     }
  23.     for($i=1;$i<7;$i++)
  24.     {
  25.         $i2=spp($row[nis],$i);
  26.         $s.="\n\t<td>Rp  ".number_format($i2)."</td>";
  27.         $aTot[$i]+=$i2;
  28.     }
  29.     $s.="\n\t</tr>";
  30. echo $s;$s='';
  31. }
  32.  
  33. $s.="\n<tr>";
  34. $s.="\n\t<td colspan=2>JUMLAH</td>";
  35.     for($i=7;$i<=12;$i++)
  36.     {
  37.         $s.="\n\t<td  >$aTot[$i]</td>";
  38.     }
  39.     for($i=1;$i<7;$i++)
  40.     {
  41.         $s.="\n\t<td  >$aTot[$i]</td>";
  42.     }
  43. $s.="</tr>";
  44.  
  45. $s.="</table>";
  46. echo $s;$s='';
  47.  
  48. function spp($nis,$bulan)
  49. {
  50. global $mysqli;
  51.     $sql="
  52.     where nis='$nis' and bulan='$bulan' ";
  53.     $q=$mysqli->query($sql);
  54.     if(!$q)
  55.     {
  56.         die($mysqli->error);
  57.     }
  58.     $n=0;
  59.      
  60.  $row = $q->fetch_assoc())
  61.  
  62.     return $row[jumlah_bayar];
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement