如何使用fpdf在所有页面中设置表格标题?

时间:2018-11-22 09:52:05

标签: php html

我想在所有页面中显示表格标题。但在第一页中,表格标题显示的其他页面则不显示

                   <?php
                //include connection file
                include_once("connection.php");
                include_once('libs/fpdf.php');

                class PDF extends FPDF
                {
                // Page header
                function Header()
                {
                    // Logo
                    $this->Image('logo.png',10,-1,70);
                    $this->SetFont('Arial','B',13);
                    // Move to the right
                    $this->Cell(80);
                    // Title
                    $this->Cell(80,10,'Employee List',1,0,'C');
                    // Line break
                    $this->Ln(20);
                }

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



                $db = new dbObj();
                $connString =  $db->getConnstring();
                $display_heading = array('id'=>'ID', 'employee_name'=> 'Name', 'employee_age'=> 'Age','employee_salary'=> 'Salary',);

                $result = mysqli_query($connString, "SELECT id, employee_name, employee_age, employee_salary FROM employee") or die("database error:". mysqli_error($connString));
                $header = mysqli_query($connString, "SHOW columns FROM employee");

                $pdf = new PDF();
                //header
                $pdf->AddPage();
                //foter page
                $pdf->AliasNbPages();
                $pdf->SetFont('Arial','B',12);
                foreach($header as $heading) {
                $pdf->Cell(40,12,$display_heading[$heading['Field']],1);
                }
                foreach($result as $row) {
                $pdf->Ln();
                foreach($row as $column)
                $pdf->Cell(40,12,$column,1);
                }
                $pdf->Output();
                ?>

如何在所有页面中包含表格标题。请帮助我解决此问题。我尝试了其他所有未给出结果的方法。

0 个答案:

没有答案