我正在使用HTML进行PDF方法在why中进行PDF编码。我成功地从数据库中检索了数据,我正在获得在行之间的更多空格,为什么??请告诉我。这是我的密码..。
require('WriteHTML.php');
include('connection.php');
$result = pg_query($db,"SELECT dvn_cd, allotment_date,allotment_no,quantity FROM ddhs_receipt_entry ");
$pdf=new PDF_HTML();
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak(true, 15);
$pdf->AddPage();
$pdf->Image('logo.png',18,13,33);
$pdf->SetFont('Arial','B',14);
$pdf->WriteHTML('<para><h1>Title</h1><br>');
$pdf->SetFont('Arial','B',7); 
$htmlTable='<TABLE>
<TR>
<TD>Name</TD>
<TD>Email</TD>
<TD>URl</TD>
<TD>Comment</TD>
</TR>
</TABLE>';
$pdf->WriteHTML2("$htmlTable");
while($value = pg_fetch_array($result)) {
$htmlTable2='<TABLE>
<TR>
<TD>'.$value['dvn_cd'].'</TD>
<TD>'.$value['allotment_date'].'</TD>
<TD>'.$value['allotment_no'].'</TD>
<TD>'.$value['quantity'].'</TD>
</TR>
</TABLE>';
$pdf->WriteHTML2("$htmlTable2");
$pdf->SetFont('Arial','B',6);
 }
 $pdf->Output(); 发布于 2015-08-17 08:52:18
实际上,您所做的是输出许多单独的表,并且您需要一个单独的表。尝试将<TABLE>移到while循环之外:
$htmlTable = '<TABLE>
    <TR>
    <TD>Name</TD>
    <TD>Email</TD>
    <TD>URl</TD>
    <TD>Comment</TD>
    </TR>';    // The table is opened at the start of this block, and headers are output
while($value = pg_fetch_array($result)) {
    $htmlTable .= '<TR>
        <TD>'.$value['dvn_cd'].'</TD>
        <TD>'.$value['allotment_date'].'</TD>
        <TD>'.$value['allotment_no'].'</TD>
        <TD>'.$value['quantity'].'</TD>
        </TR>';    // Each row of your table is added to the string here
}
$htmlTable .= '</TABLE>';    // The table is closed here
$pdf->WriteHTML2("$htmlTable");    // The table is written here
$pdf->Output();发布于 2015-08-17 08:54:15
试试这个:
while($value = pg_fetch_array($result)) {
$htmlTable2='<TR>
    <TD>'.$value['dvn_cd'].'</TD>
    <TD>'.$value['allotment_date'].'</TD>
    <TD>'.$value['allotment_no'].'</TD>
    <TD>'.$value['quantity'].'</TD>
    </TR>';
$pdf->WriteHTML2("$htmlTable2");
$pdf->SetFont('Arial','B',6);
 }
$htmlTable='</TABLE>';https://stackoverflow.com/questions/32046083
复制相似问题