ผมใช้เพื่อreport ออกมาเป็น pdf
<?
class PDF extends FPDF
{
//Simple table
function BasicTable($header,$data)
{
//Header
foreach($header as $col)
$this->Cell(40,7,$col,1);
$this->Ln();
//Data
foreach($data as $row)
{
foreach($row as $col)
$this->Cell(40,6,$col,1);
$this->Ln();
}
}
}//end class
mysql_select_db($dbname) or ("non");
$sql = "select * from member ";
$dbquery = mysql_db_query($dbname,$sql);
$i=0;
while($arr) {
$data[$i][0] = $arr['name'];
$data[$i][1] = $arr['surname'];
$i++;
}
//create object pdf
$pdf = new PDF();
$pdf->SetFont('Arial','',14);
$pdf->AddPage();
$pdf->BasicTable($header,$data);
$pdf->Output();
?>
พอรันมันขึ้นว่า
Warning: Invalid argument supplied for foreach() in c:\appserv\www\pdf\repmember_printpdf1.php on line 9
Warning: Invalid argument supplied for foreach() in c:\appserv\www\pdf\repmember_printpdf1.php on line 13
FPDF error: Some data has already been output, can't send PDF file