从数据库中调用数据作为标题

时间:2019-02-12 00:10:41

标签: php mysql database fpdf

我正在用php和fpdf做作业。我想从数据库中调用某些数据,并将其显示在标题旁边。我仍在学习,找不到任何有用的教程,这些教程都可以为我提供建议。我希望你们能帮助我。

<?php

mysqli_connect('localhost', 'root', '');

mysqli_select_db('storm');

$sql="SELECT * FROM twothree ORDER BY ssh DESC";

$records=mysql_query($sql);

require("library/fpdf.php");

class PDF extends FPDF{
function Header(){
    $this->SetFont('Arial', '', 10);
    $this->cell(12);
    $this->Image('logo.png',40,12,17);

    $this->Ln(5);
}
function Footer(){

    $this->SetFont('Arial', 'I', 8);
    $this->MultiCell(200,3,"\n - The public and the disaster risk reduction and management council concerned are advised to take appropriate actions and precautionary \nmeasures, and watch for the next storm surge information. \n- Inundation/flood depth due to storm surge will depend on the topography of the area(s). \n ",1,'L');

    $this->SetY(-15);
    $this->setFont('Arial','',8);
    $this->cell(0,10,'Page '.$this->PageNo()." / {pages}",0,0,'C');
}
}

$pdf = new PDF('p', 'mm', 'Legal');
$title = 'Storm Surge';
$pdf->SetTitle($title);
$pdf->AliasNbPages('{pages}');
$pdf->SetAutoPageBreak(true,15);

$pdf->AddPage();

$pdf->SetFont('Arial', 'B', 10);
$pdf->MultiCell(200,4,"   \nSTORM SURGE INFORMATION \nSTORM SURGE: WARNING #01 \nFOR: TYPHOON ROSITA (YUTU) \nISSUED AT 11AM, 29 October 2018 \n   ",1,'C', false);

$pdf->SetBorders(array('LT', 'LT', 'LT', 'LT', 'TLR'));
$pdf->SetWidths(array(30, 30, 40, 50, 50));
$pdf->SetAligns(array('C', 'C', 'C', 'C', 'C'));

$pdf->SetFont('Arial', 'B', 10);

$pdf->Row(array("SS Height",
            "Provinces",
            "Low Lying Coastal Areas in the Municipalities of:",
            "IMPACTS",
            "ADVICE/Actions to Take"), 1);

$pdf->SetFont('Arial', '', 11);

while($row = mysql_fetch_array($records)){

$pdf->Row(array($row['ssh'],
$row['provi'],
$row['muni'],
$row['impact'],
$row['advice']), 1);
}

$pdf->SetBorders(array('T', 'T', 'T', 'T', 'T'));
$pdf->Row(array('','','','',''), 1, false, 1);


$pdf->OutPut();
?>

所以我希望它输出像下面所附的图片一样。将从数据库中调用“警告”编号,并与“台风名称”以及时间和日期相同。

This is the picture

0 个答案:

没有答案