我在使用FPDF文件中的select语句显示数据库中的信息时遇到问题。我创建了两个文件。第一个文件,用户输入DonorID并点击创建发票。该文件指向fpdf文件,该文件将创建一个pdf文件并显示发票。它有一个select语句似乎没有产生任何结果。其他所有内容都正确显示,但表格未显示数据库中的任何信息。
这是第一个名为createinvoice.php的文件:
<!DOCTYPE html>
<html>
<title> Create Invoice Page</title>
<head>
</head>
<body>
<h1>Create Invoice</h1>
<form action="invoicereportpdf.php" method="POST">
<p>Create an invoice by typing in the Donor ID</BR>
Donor ID: <input type= "text" name="donorid" size="15"/></br>
<br>
<div id="container" style="width:900px">
<br>
<input type= "submit" name= "submit" value="Create Invoice"/>
<?php include '/html/includedonations.php'; ?>
</div>
</body>
</html>
这是第一个名为invoicereportpdf.php
的文件<?php
define('FPDF_FONTPATH','font/');
require('mysql_table.php');
class PDF extends PDF_MySQL_Table
{
function Header()
{
//Title
$this->SetFont('Arial','',14);
$this->Cell(0,6,'Invoice',0,1,'C');
$this->Ln(10);
$this->Cell(0,6,'From',0,1,'C');
$this->Ln(12);
$this->Cell(0,6,'Vetsports.org',0,1,'C');
$this->Ln(14);
$this->Cell(0,6, 'Thank you for your donation to Vetsports.org, your
donation is greatly appreciated.',0,1,'L');
$this->Ln(16);
$this->Cell(0,6, 'Please keep this receipt for your tax
purposes.',0,1,'L');
$this->Ln(16);
//Ensure table header is output
parent::Header();
}
}
//Connect to database
mysql_connect('localhost','root','');
mysql_select_db('charitabledb');
$donorid=$_POST['donorid'];
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
//table: specify 4 columns
$pdf->AddCol('ID',15,'ID','C');
$pdf->AddCol('date',15,'Date','C');
$pdf->AddCol('donorid',25,'Donor ID','C');
$pdf->AddCol('firstname',25,'First Name','L');
$pdf->AddCol('lastname',25,'Last Name','L');
$pdf->AddCol('paymenttype',35,'Payment Type','L');
$pdf->AddCol('organization',30,'Organization','L');
$pdf->AddCol('Income',40,'Amount Donated','L');
$prop=array('HeaderColor'=>array(255,150,100),
'color1'=>array(210,245,255),
'color2'=>array(255,255,210),
'padding'=>2);
$pdf->Table('select ID,date,donorid,firstname,lastname,paymenttype,organization,Income from donations where donorid="$donorid" order by date ',$prop);
$pdf->Output();
?>
答案 0 :(得分:0)
是的,所以,我有错误的引号。以下是我必须改变我的陈述“(”选择ID,日期,捐赠者,名字,姓氏,支付类型,组织,捐赠收入,捐赠者='$ donorid',$ prop);