fpdf-如何将数据分为3列?

问题描述

我已经尝试过foreach函数array_chunk,但是我无法在3列中显示数据。此代码为所有三列打印相同的日期。我有完整的报告PDF,但是此页面需要分成3个数组并打印。我删除了所有示例代码,因为它们都不起作用。谢谢您的指导。

<?PHP 
require ('conn.PHP');
require ('lib/fpdf.PHP'); 

// account or item_code for practice -- will be getting from a GET statment 
$item_code= 9999;
// query to get fields for top part of form
$info=MysqLi_query($conn,"SELECT * FROM practice WHERE item_code = $item_code");
while($row=MysqLi_fetch_array($info)){
  $firstname = $row['firstname'];
  $lastname = $row['lastname']; 
  $street = $row['street'];
  $city = $row['city'];
  $st = $row['st'];
  $zip = $row['zip'];
  $name = "{$row['lastname']},{$row['firstname']} ";
  $csz = "{$row['city']},{$row['st']} {$row['zip']}";
}

class PDF extends FPDF
{
  // Page header
  function Header()
  {
    // logo
    // $this->Image('sample.png',10,6,30);
    // Arial bold 15
    $this->SetFont('Arial','B',15);
    // Move to the right
    $this->Cell(80);
    // Title
    $this->Cell(30,' ','C');
    // Line break
    $this->Ln(1);
  }
  
  // Page footer
  function Footer()
  {
    
    // Position at 1.5 cm from bottom
    $this->SetY(-30);
    $this->SetFont('Arial','I',16);
    $this->Cell(0,'Thank You!','C');
    $this->Ln(4);
    $this->Ln(4);
    // Arial italic 8
    $this->SetFont('Arial',8);
    $this->Cell(0,'ADDRESS','C');
    $this->Ln(4);
    $this->Cell(0,'TAX ID 99-9999999 www..com','C');
    $this->Ln(4);
    // Page number
    $this->Cell(0,'Page '.$this->PageNo().'/{nb}','C');
  }
}

/*A4 width : 219mm*/

$pdf = new PDF('P','mm','A4');
$pdf->AliasNbPages();


$pdf->AddPage();
/*output the result*/

/*set font to arial,bold,14pt*/
$pdf->SetFont('Arial',20);

$pdf->SetDrawColor(180,180,255);

/*Cell(width,height,text,border,end line,[align])*/
$pdf->Cell(50,'',1);
$pdf->Cell(50,1);


$pdf->Cell(71,0);
$pdf->Cell(59,5,'TITLE','C');
$pdf->Cell(59,1);

$pdf->SetFont('Arial',15);
$pdf->Cell(200,'2020 LIST','C');
$pdf->Cell(19,1);


$pdf->SetFont('Arial',15);
$pdf->Cell(130,0);
$pdf->SetFont('Arial',10);
$pdf->Cell(189,1);

$pdf->Cell(50,15);
$pdf->Cell(15,0);
$pdf->Cell(30,$name,0);
$pdf->Cell(56,10);
$pdf->Cell(15,0);
$pdf->Cell(115,$street,0);
$pdf->Cell(25,' Account ID:',0);
$pdf->Cell(34,$item_code,1);
$pdf->Cell(15,$csz,0);

$pdf->Cell(59,'Any Questions Contact: Don',1);


$pdf->Cell(130,0);
$pdf->Cell(58,'don@.org',0);
$pdf->Cell(1,1);
$pdf->Cell(1,'_','C');
$pdf->Cell(190,'C');
$pdf->Cell(2,'C');
$pdf->Cell(130,'Contributions',1);


$pdf->Cell(100,'Check List',1);

$pdf->SetFillColor(180,255);
$pdf->SetDrawColor(180,255);

//   $pdf->Cell(10,1,0);
$pdf->Cell(15,'Date','Ckno',0);
$pdf->Cell(17,'Amt','R');
$pdf->Cell(10,'R');


$query=MysqLi_query($conn,"SELECT * FROM practice WHERE item_code = $item_code ORDER BY item_date ASC");
while($data=MysqLi_fetch_array($query)){
  $odate=$data['item_date'];
  $date = date("m-d",strtotime($odate));

  //$pdf->Cell(10,'LR',0);
  $pdf->Cell(15,$date,0);
  $pdf->Cell(25,$data['item_desc'],0);
  $pdf->Cell(17,$data['order_item_price'],'R');
  $pdf->Cell(10,'R');
}

$pdf->Output();

?>

the report per the code

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)