mysql数据库到pdf?

时间:2013-10-14 10:39:02

标签: php mysql pdf fpdf

我想从数据库中检索特定销售人员的数据并下载检索pdf file.im中的数据,使用下面的代码,它只显示页面的结构和页面的标题,而不是从我想要的表中购买详细信息。任何人帮助我

这是代码:

 <?php

 include "test4.php";
 include('fpdf/fpdf.php');
 $pdf=new FPDF();

 //Creating new pdf page
 $pdf->AddPage();


  $pdf->SetRightMargin(50);
  $margin;

  // Insert a logo in the top-left corner at 300 dpi
  $pdf->Image('images/logo7.png',5,5,-100);
  // Insert a dynamic image from a URL
  $pdf->Ln(20);

  $pdf->Ln();
  //Set the base font & size
  $pdf->SetFont('Arial','B',18); 
  $pdf->Cell(200,5,"Booth Sales Reports",0,0,'C');
  //Creating new line
  $pdf->Ln();
  $pdf->Ln();
  $pdf->SetFont('Arial','i',12);
  $pdf->Cell(40,10,"Company Name",0,'C');
  $pdf->Cell(40,10,"Contact Person",0,'C');



 $pdf->Cell(40,10,"Booth Number",0,'C');

 $pdf->Cell(40,10,"Phone Number",0,'C');

 $pdf->Cell(30,10,"Date",0,'C');
 $pdf->Ln();
         $pdf->Cell(200,-2,"__________________________________");



   // Fetch data from table
     $c=$_SESSION['user'];
     $result=mysql_query("SELECT  `company_name`, `contact_person`,  `phone_number`, `booth_number`, `date` FROM `registration1` where 'sold_by' ='$c' ");
    while($row=mysql_fetch_array($result))
  {
  $pdf->Cell(40,5,"{$row['company_name']}",1,0,'C');
  $pdf->Cell(40,5,"{$row['contact_person']}",1,0,'C');




  $pdf->Cell(40,5,"{$row['phone_number']}",1,0,'C');

  $pdf->Cell(40,5,"{$row['booth_number']}",1,'C');

  $pdf->multiCell(30,5,"{$row['date']}",1,'C');
  }
 $pdf->Output();
  ?>

这个编码没有显示

2 个答案:

答案 0 :(得分:0)

去那里:fpdf.org然后是脚本 - &gt;表与Mysql。那应该可以解决你的问题 http://fpdf.org/en/script/script14.php

答案 1 :(得分:0)

$result=mysql_query("SELECT  `company_name`, `contact_person`,  `phone_number`, `booth_number`, `date` FROM `registration1` where 'sold_by' ='$c' ");
while($row=mysql_fetch_array($result))
{
    $pdf->Cell(40,5,$row['company_name'],1,0,'C');
    $pdf->Cell(40,5,$row['contact_person'],1,0,'C');
    $pdf->Cell(40,5,$row['phone_number'],1,0,'C');
    $pdf->Cell(40,5,$row['booth_number'],1,'C');
    $pdf->multiCell(30,5,$row['date'],1,'C');
}

试试这个