2013-04-08 68 views
0

我在與一個FPDF文件中使用SELECT語句從數據庫顯示信息的問題顯示。我創建了兩個文件。第一個文件,用戶輸入DonorID並點擊創建發票。該文件指向fpdf文件,並創建一個pdf文件並顯示發票。它有一個select語句,似乎沒有產生任何結果。一切正常顯示,但表格不顯示數據庫中的任何信息。有一個問題,從數據庫中選擇使用,PHP FPDF

這是第一個文件,名爲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

我相信它有一些事情與我的select語句,因爲當我脫下其中donorid =「$ donorid」它與出來的問題。 – 2013-04-09 00:11:25

+0

對,所以,我錯了引號。以下是我不得不改變我的聲明」 (「選擇ID,日期,捐贈者,名字,姓氏,付款類型,組織,捐款收入,其中donorid ='$ donorid'」,$ prop); – 2013-04-09 00:17:28

回答

0

右一稱爲第二個文件,所以,我有錯誤的引號。以下是我不得不改變我的聲明」(‘選擇編號,日期,donorid,名字,姓氏,paymenttype,組織,捐贈收入,其中donorid =‘$ donorid’’,$道具);

相關問題