ariestamirra

Untitled

Sep 12th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2. include("config.php");
  3.     $query = "SELECT * FROM tek_rekap_mhs ORDER BY no";
  4.     $sql = mysql_query ($query);
  5.     $data = array();
  6.     while ($row = mysql_fetch_assoc($sql)){
  7.         array_push($data, $row);
  8.     }
  9.    
  10.     $judul = "Rekapitulasi Jumlah Mahasiswa";
  11.     $header = array(
  12.         array("label"=>"No", "length"=>25, "align"=>"C"),
  13.         array("label"=>"Jurusan", "length"=>100, "align"=>"C"),
  14.         array("label"=>"Jumlah Mahasiswa", "length"=>50, "align"=>"C"),
  15.     );
  16.    
  17.     require_once ("fpdf17/fpdf.php");
  18.     $pdf = new FPDF();
  19.     $pdf->AddPage();
  20.    
  21.     $pdf->SetFont('Arial','B','16');
  22.     $pdf->Cell(0,20, $judul, '0', 1, 'C');
  23.    
  24.     $pdf->SetFont('Arial','','10');
  25.     $pdf->SetFillColor(79,79,87);
  26.     $pdf->SetTextColor(255);
  27.     $pdf->SetDrawColor(79,79,87);
  28.     foreach ($header as $kolom) {
  29.         $pdf->Cell($kolom['length'], 5, $kolom['label'], 1, '0', $kolom['align'], true);
  30.     }
  31.     $pdf->Ln();
  32.    
  33.     $pdf->SetFillColor(199,200,203);
  34.     $pdf->SetTextColor(0);
  35.     $pdf->SetFont('');
  36.     $fill=false;
  37.     foreach ($data as $baris) {
  38.         $i = 0;
  39.         foreach ($baris as $cell) {
  40.             $pdf->Cell($header[$i]['length'], 5, $cell, 1, '0', $i==1?"L":$kolom['align'], $fill);
  41.             $i++;
  42.         }
  43.         $fill = !$fill;
  44.         $pdf->Ln();
  45.     }
  46.     $pdf->Output();
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment