master master saya newbie nih udah keliling keliling cari cara tutorial bikin report pake fpdf ga masih ga ngerti aja
nah saya buat aja di php nya cara ke yii innya gimana yah ? makasih para master
<?php
//koneksi ke database
$host = "localhost";
$user = "root";
$pass = "";
$dbnm = "aplikasi";
$conn = mysql_connect($host, $user, $pass);
if ($conn) {
$open = mysql_select_db($dbnm);
if (!$open) {
die ("Database tidak dapat dibuka karena ".mysql_error());
}
} else {
die ("Server MySQL tidak terhubung karena ".mysql_error());
}
$query = mysql_query("select * from penjualan");
$data = array();
while($row = mysql_fetch_assoc($query)){
array_push($data,$row);
}
$judul = "Laporan Penjualan";
$header = array(
array("label"=>"ID","length"=>30,"align"=>"L"),
array("label"=>"Kode Jual","length"=>30,"align"=>"L"),
array("label"=>"Nama Jual","length"=>40,"align"=>"L"),
array("label"=>"Singakatan Nama","length"=>40,"align"=>"L")
);
require_once(‘fpdf/fpdf.php’);
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont(‘Arial’,‘B’,‘16’);
$pdf->Cell(0,20, $judul, ‘0’, 1, ‘C’);
$pdf->SetFont(‘Arial’,’’,‘10’);
$pdf->SetFillColor(255,0,0);
$pdf->SetTextColor(255);
$pdf->SetDrawColor(128,0,0);
foreach ($header as $kolom) {
$pdf->Cell($kolom[‘length’], 5, $kolom[‘label’], 1, ‘0’,
$kolom[‘align’], true);
}
$pdf->Ln();
$pdf->SetFillColor(224,235,255);
$pdf->SetTextColor(0);
$pdf->SetFont(’’);
$fill=false;
foreach ($data as $baris) {
$i = 0;
foreach ($baris as $cell) {
$pdf->Cell($header[$i][‘length’], 5, $cell, 1, ‘0’,
$kolom[‘align’], $fill);
$i++;
}
$fill = !$fill;
$pdf->Ln();
}
$pdf->Output();
?>
?>