fpdf - How to call an array outside a class using PHP and Codeigniter? -


hello guys need little here accessing data array outside class i'm confused on how show variable outside class here's code below:

<?php  date_default_timezone_set('asia/manila');  require('resources/fpdf/fpdf.php');  class pdf extends fpdf {      function header(){          //here place should put array, cant access 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 * po_order_details order_code = '".$code."'";  $result = $this->db->query($query); foreach($result->result_array() $row){     $data[] = array($row['item_qty'],  //this array need                     $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 $pdf->setfillcolor(255,0,0); $pdf->ln(); $pdf->addpage(); $pdf->buildtable($header,$data); $pdf->ln(); $pdf->output();  ?> 

that's hope can me

why not change prototype of header method , pass array parameter this.

<?php  date_default_timezone_set('asia/manila');  require('resources/fpdf/fpdf.php');  class pdf extends fpdf {      function header( &$titles, &$data ){          //here place should put array, cant access inside         // use $titles , $data here          $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 * po_order_details order_code = '".$code."'";  $result = $this->db->query($query); foreach($result->result_array() $row){     $data[] = array($row['item_qty'],  //this array need                     $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 $pdf->header( $header, $data );  $pdf->setfillcolor(255,0,0); $pdf->ln(); $pdf->addpage(); $pdf->buildtable($header,$data); $pdf->ln(); $pdf->output();  ?> 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -