FPDF 显示 Table 之外的数据库中的数据

FPDF Display Data From Database Outside The Table

我正在重新发布我的 question 以便获得更多观众。自从我上周发布后,其他人似乎没有看到它。

我正在 table 内外显示数据。当我试图在 table 内部调用数据时,它工作得很好,但每当我在外部调用它时,它突然不显示。这部分就在这里...

$pdf->MultiCell(194,4,"STORM SURGE INFORMATION",0,'C', false);
$pdf->Cell(191,4,"STORM SURGE: WARNING # ",0,0,'C');
$pdf->Cell(-136,4,$fetch['warning'],0,1,'C');

$pdf->Cell(172,4,"FOR: TYPHOON ",0,0,'C');
$pdf->Cell(-119,4,$fetch['typhoon'],0,1,'C');

$pdf->Cell(175,4,"ISSUED AT ",0,0,'C');
$pdf->Cell(-135,4,$fetch['date'],0,1,'C');

我的 PDF 目前是这样的。

有人可以帮我找出我的代码有什么问题或缺失吗?

<?php

require("con.php");

$sql="SELECT * FROM table ORDER BY ssh REGEXP '^[^A-Za-z0-9]' ASC, ssh DESC";

$records=mysql_query($sql);
$fetch = $records[0];

require("library/fpdf.php");

class PDF extends FPDF{
  function Header(){
  }
  function Footer(){
  }
}

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

$pdf->AddPage();
$pdf->Ln();

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

$pdf->MultiCell(194,4,"STORM SURGE INFORMATION",0,'C', false);
$pdf->Cell(191,4,"STORM SURGE: WARNING # ",0,0,'C');
$pdf->Cell(-136,4,$fetch['warning'],0,1,'C');

$pdf->Cell(172,4,"FOR: TYPHOON ",0,0,'C');
$pdf->Cell(-119,4,$fetch['typhoon'],0,1,'C');

$pdf->Cell(175,4,"ISSUED AT ",0,0,'C');
$pdf->Cell(-135,4,$fetch['date'],0,1,'C');

$pdf->Ln(1);

$pdf->SetBorders(array('LT', 'LT', 'LT', 'LT', 'TLR'));
$pdf->SetWidths(array(25, 27, 35, 54, 53));
$pdf->SetAligns(array('C', 'C', 'C', 'L', 'L'));

$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();
?>

您正在尝试使用负 X 位置值。我希望,这就是它不起作用的原因。

你想要下面这样的东西吗:

例子

使用限制获取最新记录

$sql="SELECT * FROM twothree ORDER BY ssh REGEXP '^[^A-Za-z0-9]' ASC, ssh DESC LIMIT 1";
//echo $sql;
$records=mysql_query($sql);
if (mysql_num_rows($records)) {
 $fetch = mysql_fetch_assoc($records);
}

$pdf->Ln(10);
$pdf->Cell(194, 4,"STORM SURGE: WARNING # " . $fetch['warning'], 0,0,'C');
$pdf->Ln();
$pdf->Cell(194, 4,"FOR: TYPHOON " . $fetch['typhoon'],0,0,'C');
$pdf->Ln();
$pdf->Cell(194,4,"ISSUED AT " . $fetch['date'],0,0,'C');
$pdf->Ln();

$pdf->Ln(20);

例子

$pdf->Cell(60, 4,"", 0,0,'C');
$pdf->Cell(60, 4,"STORM SURGE: WARNING # :", 0,0,'L');
$pdf->setX(125);    
$pdf->Cell(60, 4,$fetch['warning'], 0,0,'L');
$pdf->Ln();
$pdf->Cell(60, 4,"", 0,0,'C');
$pdf->Cell(60, 4,"FOR: TYPHOON :", 0,0,'L');
$pdf->setX(100);    
$pdf->Cell(60, 4,$fetch['typhoon'], 0,0,'L');
$pdf->Ln();
$pdf->Cell(60, 4,"", 0,0,'C');
$pdf->Cell(60, 4,"ISSUED AT : ", 0,0,'L');
$pdf->setX(100);    
$pdf->Cell(60, 4,$fetch['date'], 0,0,'L');
$pdf->Ln();

主查询

$sql="SELECT * FROM twothree ORDER BY ssh REGEXP '^[^A-Za-z0-9]' ASC, ssh DESC";
//echo $sql;
$records=mysql_query($sql);