【问题标题】:mysql database to pdf? [duplicate]mysql数据库转pdf? [复制]
【发布时间】:2013-10-21 21:50:07
【问题描述】:

我想从数据库中检索特定销售人员的数据,并使用以下代码下载在 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();
  ?>

这个编码什么都不显示

【问题讨论】:

    标签: php mysql pdf fpdf


    【解决方案1】:

    去那里:fpdf.org 然后是 Scripts -> Table with Mysql。那应该可以解决您的问题 http://fpdf.org/en/script/script14.php

    【讨论】:

    • 我已经尝试过了,但它不起作用,在上面的编码中,当我使用另一个查询(如 sold_by 订购)时,它工作但在该查询中不起作用
    • 有错误提示吗?
    【解决方案2】:
    $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');
    }
    

    试试这个

    【讨论】:

      猜你喜欢
      • 2015-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-26
      • 1970-01-01
      • 2010-12-25
      • 2018-05-18
      • 2013-02-25
      相关资源
      最近更新 更多