0

我在使用 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();
?> 
4

1 回答 1

0

对,所以,我有错误的报价。以下是我必须更改声明的方法" ("select ID,date,donorid,firstname,lastname,paymenttype, organization,Income fromdonations where donorid= '$donorid'",$prop);

于 2013-04-12T05:06:20.690 回答