Php FPDF创建装运标签
我正在尝试使用FPDF创建我的一个数据库表的pdf。基本上,我想点击一个Php FPDF创建装运标签,php,mysql,fpdf,Php,Mysql,Fpdf,我正在尝试使用FPDF创建我的一个数据库表的pdf。基本上,我想点击一个打印按钮,让信息自动填充到PDF上。我自己尝试过的都失败了,我似乎无法理解这一点 确保使用$pdf->Output()带有选项,例如$pdf->Output('I') 有关函数/类的更多信息,请参见此处问题到底是什么?PDF总是显示为空白。我不确定这是我的语法还是什么,但只有我的徽标和标题appeartfm:函数返回一个语句句柄。您试图将该句柄视为一个结果数组。您需要首先从该句柄获取行。所以,创建一个信息数组不是正确的处
打印
按钮,让信息自动填充到PDF上。我自己尝试过的都失败了,我似乎无法理解这一点
确保使用
$pdf->Output()代码>带有选项,例如$pdf->Output('I')代码>
有关函数/类的更多信息,请参见此处问题到底是什么?PDF总是显示为空白。我不确定这是我的语法还是什么,但只有我的徽标和标题appeartfm:函数返回一个语句句柄。您试图将该句柄视为一个结果数组。您需要首先从该句柄获取行。所以,创建一个信息数组不是正确的处理方法吗?
<?php
require("fpdf/fpdf.php");
mysql_connect("localhost", "[username]","[password]") or die ("Could not connect to database");
mysql_select_db("[db_name]") or die ("Could not select database");
$query = "SELECT ID_Shipping, ID_Order, Shipping_Company FROM SeniorDB_Shipping ORDER BY `ID_Shipping` ";
$result = mysql_query($query) or die('Error, query failed');
$num_rows = mysql_num_rows($result);
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('minilogo.png',10,6,50);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(55,10,'Shipping Information',1,0,'C');
// Line break
$this->Ln(20);
}
}
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
//$pdf->Cell(40,10,'Hello World!');
while (TRUE) {
if ($row=$result[$i]) {
//positions set above
$LabelText = sprintf("%s\n%s %s\n%s, %s, %s",
$row['ID_Shipping'],
$row['ID_Order'],
$row['Shipping_Company']);
Avery5160($x,$y,&$pdf,$LabelText);
$y++; // next row
if ($y == 10 ) { // end of page wrap to next column
$x++;
$y = 0;
if ($x == 3 ) { // end of page
$x = 0;
$y = 0;
$pdf->AddPage();
}
}
$i++; //counter through result
} else {
// Error quit printing
break;
}
}
$pdf->Output();
?>