【问题标题】:Having an Issue Displaying from Database Using Select, PHP, FPDF使用 Select、PHP、FPDF 从数据库显示时出现问题
【发布时间】:2013-04-08 23:56:20
【问题描述】:

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

【问题讨论】:

  • 我确实认为这与我的 select 语句有关,因为当我取消 where donorid="$donorid" 时,它没有问题。
  • 对,所以,我有错误的报价。这是我必须更改我的声明的方法" ("选择 ID、日期、捐赠者、名字、姓氏、付款类型、组织、捐赠收入 where donorid= '$donorid'",$prop);

标签: php mysql fpdf


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-05-31
    • 2014-09-23
    • 1970-01-01
    • 2014-12-15
    • 1970-01-01
    • 2021-07-01
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    相关资源
    最近更新 更多