php – 在FPDF中显示值

前端之家收集整理的这篇文章主要介绍了php – 在FPDF中显示值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我在PHP中使用FPDF生成pdf的代码.我想在PDF文件显示学期,账单月和billyear.我不想在表格中显示值.
我想显示页面顶部.我怎样才能做到这一点?有什么建议吗?提前致谢.干杯.
<?PHP

    session_start();
    require('fpdf/fpdf.PHP');

    //Connect to your database

    $r1=$_SESSION['sem1'];

    $con=MysqL_connect('localhost','root','');

    if(!$con)
    {
    die('Unable to connect'.MysqL_error());
    }
    MysqL_select_db('hostel',$con);

    $result=MysqL_query("SELECT r.hosteladmissionno,r.student_name,r.semester,r.blockname
           r.branch,m.billmonth,m.billyear,(s.days_mess*perdayrate) AS mess_charges,m.perdayrate,s.days_mess,s.nv_tokens
           FROM registration r,student_month s,messexp m
           WHERE  s.hosteladmissionno = r.hosteladmissionno 
           AND r.mess_type=m.messtype
           AND m.billmonth = 'March' AND m.billyear= '2014'");
         $number_of_products = MysqL_numrows($result);

    while($row = MysqL_fetch_array($result))
    {
        $hostad = $row['hosteladmissionno'];
        $name = $row['student_name'];
        $block=$row['blockname'];
        $branch=$row['branch'];
        $perday=$row['perdayrate'];
        $days=$row['days_mess'];
        $messch= $row['mess_charges'];
        $nv=$row['nv_tokens'];




        $column_no = $column_no.$hostad."\n";
        $column_name = $column_name.$name."\n";
        $sem_details= $sem_details.$block."\n";
        $comm_details= $comm_details.$branch."\n";
        $course_details= $course_details.$perday."\n";
        $courseyr_details= $courseyr_details.$days."\n";
        $mess_details= $mess_details.$messch."\n";
        $block_details= $block_details.$nv."\n";



    }
    MysqL_close();

    //Create a new PDF file
    $pdf=new FPDF('P','mm','A4');

    $pdf->AddPage();

    //Fields Name position
    $Y_Fields_Name_position = 40;
    //Table position,under Fields Name
    $Y_Table_Position = 46;
    $pdf->Cell(15,50,'Anna University Hostels');
    //First create each Field Name
    //Gray color filling each Field Name Box
    $pdf->SetFillColor(232,232,232);
    //Bold Font for Field Name
    $pdf->SetFont('Arial','B',9);
    $pdf->SetY($Y_Fields_Name_position);
    $pdf->SetX(5);
    $pdf->Cell(23,6,'Admission No',1,'L',1);
    $pdf->SetX(28);
    $pdf->Cell(37,'Student Name',1);
    $pdf->SetX(65);
    $pdf->Cell(18,'Block Name',1);
    $pdf->SetX(83);
    $pdf->Cell(20,'Branch',1);
    $pdf->SetX(103);
    $pdf->Cell(22,'Per Day Rate',1);
    $pdf->SetX(125);
    $pdf->Cell(22,'No of Days',1);
    $pdf->SetX(147);
    $pdf->Cell(20,'Mess charge',1);
    $pdf->SetX(167);
    $pdf->Cell(18,'NV Token',1);
    $pdf->SetX(185);
    $pdf->Cell(25,1);
    $pdf->Ln();

    //Now show the 3 columns
    $pdf->SetFont('Arial','',12);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(5);
    $pdf->MultiCell(23,$column_no,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(28);
    $pdf->MultiCell(37,$column_name,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(65);
    $pdf->MultiCell(18,$block,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(83);
    $pdf->MultiCell(20,$branch,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(103);
    $pdf->MultiCell(22,$perday,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(125);
    $pdf->MultiCell(22,$days,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(147);
    $pdf->MultiCell(20,$messch,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(167);
    $pdf->MultiCell(18,$nv,1);
    $pdf->SetY($Y_Table_Position);
    $pdf->SetX(185);
    $pdf->MultiCell(25,$block_details,1);
    $i = 0;
    $pdf->SetY($Y_Table_Position);
    while ($i < $number_of_products)
    {
        $pdf->SetX(5);
        $pdf->MultiCell(205,1);
        $i = $i +1;
    }
    $pdf->Output();
    ?>
为什么不使用FPDF的标准“header()”扩展功能
http://fpdf.org/en/doc/header.htm
原文链接:/php/133970.html

猜你在找的PHP相关文章