大家好,我在这里只需要一点帮助来访问类外的数据数组我对如何在类外显示变量感到非常困惑这是我的代码如下:
<?php
date_default_timezone_set('Asia/Manila');
require('resources/fpdf/fpdf.php');
class PDF extends FPDF {
function Header(){
//HERE IS THE PLACE WHERE SHOULD I PUT THE ARRAY, BUT I CANT ACCESS IT INSIDE
$this->SetFont('Arial','B',10);
$this->Cell(180,5,'PURCHASE ORDER',0,0,'C');
$this->Ln();
$this->SetFont('Arial','',9);
$this->Cell(40,5,'Suppliers Name:'.$data['spname'].' ');
$this->Ln();
$this->SetFont('Arial','',9);
$this->Ln(20);
}
}
$query = "SELECT * FROM po_order_details WHERE order_code = '".$code."'";
$result = $this->db->query($query);
foreach($result->result_array() as $row){
$data[] = array($row['item_qty'], //THIS IS THE ARRAY THAT I NEED TO GET
$row['spname'],
$row['spaddress'],
);
}
$this->session->set_userdata('session_data',$data);
//Column titles
$pdf = new PDF();
$header = array('QTY','ITEM / DESCRIPTION' , 'UNIT PRICE', 'TOTAL AMOUNT'); // CHANGE THIS ALSO
$pdf->SetFillColor(255,0,0);
$pdf->Ln();
$pdf->AddPage();
$pdf->BuildTable($header,$data);
$pdf->Ln();
$pdf->Output();
?>
这就是我希望你能帮助我的全部