Jump to content

FPDF Problem


RIRedinPA

Recommended Posts

I'm trying to get the table example from the FPDF website working but keep getting the following error with my script. Any help would be appreciated:

 

Error:

 

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /Library/WebServer/Dev/FPDFtest/index.php on line 22

 

line 22 = $headerarray = array("Field 1", "Field 2", "Field 3", "Field 4");

 


<?php
require("fpdi/fpdi.php");

class PDF extends FPDF { 

function BasicTable($headerarray,$data) {
    	//Header
	foreach($headerarray as $col) { 
		$this->Cell(40,7,$col,1);
    		$this->Ln();
    	//Data
    	foreach($textarray as $row) {
        	foreach($row as $col) {
            	$this->Cell(40,6,$col,1);
        		$this->Ln();
    		}
	}
} //end function

}//end class

$headerarray = array("Field 1", "Field 2", "Field 3", "Field 4"); 
$textarray = array(array("row1item1", "row1item2" , "row1item3", "row1item4"), array("row2item1", "row2item2" , "row2item3", "row2item4"), array("row3item1", "row3item2" , "row3item3", "row3item4")); 

$pdf=new FPDF('L','pt','Letter');
$pdf->SetFont('Arial','',14);
$pdf->AddPage();
$pdf->BasicTable($headerarray,$textarray);	
$pdf->Output();

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.