2017-01-06 15:26
浏览 36

如何将数据从mysql打印到pdf文件中。 页眉和页脚正在打印,但来自mysql的数据不打印

I am trying to generate a pdf form through below given script. When I generate the pdf file it only printing header and footer. I am unable to print values from database. db.php and fpdf.php are correct. Output is attached Please help.
enter image description here


    include "includes/db.php";


    class PDF extends FPDF
    // Page header
    function Header()
    // Logo
    // Arial bold 15
    // Move to the right
    // Title
    $this->Cell(60,10,'Shekhat test',0,0,'C');
    // Line break


    $this->Cell(220,10,'Pune, Maharashtra',0,0,'C');




    // Page footer
    function Footer()
    // Position at 1.5 cm from bottom
    // Arial italic 8
    // Page number
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');

    // Instanciation of inherited class
    $pdf = new PDF();


        $get_id = $_GET['print_slider'];

    $result="SELECT * FROM homeslider WHERE banner_id='$get_id'";
    //$result="SELECT * FROM homeslider";

    $rows = mysqli_query($con, $result); 

    while($row=mysqli_fetch_array($rows, MYSQLI_ASSOC))

    $pdf->Cell(0,10,'Banner id:' ,$row['banner_id']); 
    $pdf->Cell(0,10,'Banner Title:' ,$row['banner_title']);
    $pdf->Cell(0,10,'Banner Image:' ,$row['banner_image']);



  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongou4052 2017-01-07 08:59

    The problem is when you call the Cell method:

    $pdf->Cell(0,10,'Banner id:' , $row['banner_id']);

    you need to replace the comma with a period..!

    So this will work:

    $pdf->Cell(0,10,'Banner id:' . $row['banner_id']);
    解决 无用
    打赏 举报

相关推荐 更多相似问题