Code: Select all
<?
require('fpdf.php');
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
//header declare
$header=array('name','surname');
//data query from database keep to array 2 dimension
$hostname = "localhost";
$user = "root";
$password = "";
$dbname = "jnt";
$tblname = "jnt_bank";
mysql_connect($hostname,$user,$password) ;
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();
?>output error is!
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
please help! me for correct code.
d11wtq | Please read the sticky about posting code in the forums