我是FPDF的新手,我刚刚开始学习,
我正在尝试使用PHP
从数据库中显示查询这是我的代码。
<?php
session_start();
$conn = @mysql_connect("","","");
$db = @mysql_select_db("");
require("../pdf/fpdf.php");
$qry = "SELECT sum(order_detail.quantity*order_detail.price) as chenes, orders.date
FROM order_detail
LEFT JOIN orders
ON order_detail.orderid=orders.serial";
mysql_set_charset("UTF8");
$result = @mysql_query($qry);
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while ($row=mysql_fetch_array($result)){
?>
<?php
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont("Arial","","13");
$pdf->Cell(0,10,"Sales Reports",0,1,"C");
$pdf->SetFont("Arial","I","10");
$pdf->Cell(0,10,"$row[chenes]",0,0,"C");
$pdf->Output();
?>
<?php } ?>
我得到这个问题,FPDF错误:有些数据已经输出,无法发送PDF文件我该如何解决?我想显示数据库中的值,解释会很好。 :)
答案 0 :(得分:1)
试试这一行:
$ PDF-&GT;细胞(0,10,$行[ 'CHENES'],0,0, “C”);
答案 1 :(得分:0)
试试这个:
define('FPDF_FONTPATH', '../pdf/font/');
require("../pdf/fpdf.php");
$pdf=new FPDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont("Arial","","13");
$pdf->Cell(0,10,"Sales Reports",0,1,"C");
$pdf->SetFont("Arial","I","10");
while ($row=mysql_fetch_array($result)){
$pdf->Cell(0,10,$row["chenes"],0,0,"C");
}
$pdf->Output();