Advertisement
R2P

lap nilai

R2P
Jan 30th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.75 KB | None | 0 0
  1. <?php
  2. include "../config.php";
  3. // pendefinisian folder font pada FPDF
  4. define('FPDF_FONTPATH', 'FPDF/font/');
  5. require('FPDF/fpdf.php');
  6.  
  7. // seperti sebelunya, kita membuat class anakan dari class FPDF
  8.  class PDF extends FPDF{
  9.  
  10.   function Header(){
  11.   $this->Image('../FPDF/logi.jpg',5,1,2); // logo
  12.    $this->SetTextColor(0,0,0); // warna tulisan
  13.    $this->SetFont('Arial','B','30'); // font yang digunakan
  14.    // membuat cell dg panjang 19 dan align center 'C'
  15.    $this->Cell(30,1,'SANGGAR TARI TRIMUKTI PARE',0,0,'C');
  16.    $this->Ln();
  17.    $this->SetFont('Arial','B','15');
  18.    $this->Cell(30,1.5,'Jalan Wilis No. 25 Pare Kediri No. Telp: 085 736 629 091',0,0,'C');
  19.    $this->Ln();
  20.  
  21.     $this->Line(3,3.3,28,3.1);
  22.     $this->SetLineWidth(0.1);
  23.     $this->Line(3,3.4,28,3.2);
  24.     $this->SetLineWidth(0);
  25.    $this->Ln();
  26.    $this->SetFont('Arial','B','12');
  27.     $this->Cell(30,1,'Hasil Penilaian',0,0,'C');
  28.    $this->Ln();
  29.    $this->SetFont('Arial','B','10');
  30.    $this->SetFillColor(192,192,192); // warna isi
  31.    $this->SetTextColor(0,0,0); // warna teks untuk th
  32.    $this->Cell(2);
  33.    $this->Cell(4,1,'Alternatif','TB',0,'C',1); // cell dengan panjang 2
  34.    
  35.  $q = mysql_query( "SELECT k.*
  36.                FROM detail_nilai d
  37.                INNER JOIN kriteria k ON k.id_krit=d.id_krit
  38.                GROUP BY k.kriteria
  39.                ORDER BY id_krit");
  40.   while ($row=mysql_fetch_array($q)){
  41.       $this->Cell(4,1,$row['kriteria'],'TB',0,'C',1);
  42.   }
  43.    // panjang cell bisa disesuaikan
  44.    $this->Ln();
  45.   }
  46.  
  47.   function Footer(){
  48.    $this->SetY(-2,5);
  49.    $this->Cell(0,1,$this->PageNo(),0,0,'C');
  50.   }
  51.  }
  52.  
  53.  $server = "localhost";
  54.  $user = "root";
  55.  $pass = "";
  56.  $data = "wpp";
  57.  
  58.  $net = new mysqli($server, $user, $pass, $data);
  59.  
  60.  if($net->connect_error){
  61.   die("Koneksi gagal: ".$net->connect_error);
  62.  }
  63.  
  64.  $q ="SELECT  p.nama from master_nilai m
  65.      INNER JOIN penari p ON p.id_penari=m.id_penari
  66.      ORDER BY m.id_penari";
  67.  $h = $net->query($q) or die($net->error);
  68.  $i = 0;
  69.  
  70.  
  71.  while($d=$h->fetch_array()){
  72.   $cell[$i][0]=$d[0];
  73. $qu ="SELECT d.nilai_krit
  74. FROM detail_nilai d, master_nilai m, penari p
  75. WHERE d.id_nilai=m.id_nilai AND m.id_penari=p.id_penari AND p.nama='{$cell[$i][0]}'
  76. ORDER BY d.id_krit ";
  77.  $ha = $net->query($qu) or die($net->error);
  78.  $iq = 1;
  79.  while($da=$ha->fetch_array()){
  80.   $cell[$iq][1]=$da[1];
  81.   $iq++;
  82.  }
  83.   $i++;
  84.  }
  85.  // orientasi Potrait
  86.  // ukuran cm
  87.  // kertas A4
  88.  $pdf = new PDF('L','cm','A4');
  89.  $pdf->Open();
  90.  
  91.  $pdf->AliasNbPages();
  92.  $pdf->AddPage();
  93.  
  94.  $pdf->SetFont('Arial','','8');
  95.  //perulangan untuk membuat tabel
  96.  for($j=0;$j<$i;$j++){
  97.   $pdf->Cell(2);
  98.   $pdf->Cell(4,1,$cell[$j][0],'B',0,'L');
  99.  for($ja=1;$ja<$iq;$ja++){
  100.  $pdf->Cell(4,1,$cell[$ja][1],'B',0,'L');
  101.  }
  102.   $pdf->Ln();
  103.  
  104. }
  105.  $pdf->Output(); // ditampilkan
  106.  
  107. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement