我必须创建两种类型的表:一种是像一个工作正常的寄存器,第二种就像一个无效的表单。显示页面上的标题,但表格未显示。我在两者中都使用了类似的CSS和编码风格。
注意:如果有多个记录,每个页面上必须显示一个表,每个表应只使用一个页面,不超过该页面。
以下是我的代码:
<head>
<style>
.atable tr th{
background-color: #FF0000;
}
.atable tr td{
background-color: #FF0000;
}
</style>
</head>
<?php
if($result1 = $mysqli->prepare($qry))
{
//parameters are bound here
if($result1->execute())
{
$finrest=$result1->get_result();
$a='<style>@page {
margin: 10pt;
}</style>';
if ($finrest->num_rows > 0)
{
while($row= $finrest->fetch_assoc())
{
$gdImage = 'Images/img.jpg';
$a.='<h4>PAGE TITLE</h4><table width="100%" style="overflow: wrap" style="border: 1px solid black;">
<tr>
<td colspan="3" style="text-align:center;font-weight:bold;border:1px solid black;">SECTION TITLE</td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c0'] . '</font></td><td rowspan="4">' . '<div id="testimage"><img src="' . $gdImage . '" width="80pt" /></div>
</td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c1'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c2'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c3'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c4'] .'</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c5'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c6'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c7'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c8'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c9'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c10'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c11'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c12'] . ', ' .$row['c13'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c14'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c15'] . '</font></td>
</tr>
<tr>
<td colspan="3" style="text-align:center;font-weight:bold;border:1px solid black;">SECTION TITLE</td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c16'] . '</font></td><td rowspan="4">' . '<div id="testimage"><img src="' . $gdImage . '" width="80pt" /></div>
</td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c17'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c18'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c19'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c20'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title/CGPA</td><td>'. $row['c21'] . '</font></td>
</tr>
<tr>
<td colspan="3" style="text-align:center;font-weight:bold;border:1px solid black;">SECTION TITLE</td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c22'] . '</font></td><td rowspan="4">' . '<div id="testimage"><img src="' . $gdImage . '" width="80pt" /></div>
</td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c23'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c24'] . ', ' . $row['c26'] .'</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c25'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c27'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c28'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c29'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c30'] . '</font></td>
</tr>
<tr>
<td><font face="arial">Column Title</td><td>'. $row['c32'] . '</font></td>
</tr>';
//echo $a;
//exit;
}
}
else
{
echo "0 results";
}
$a.='</table>';
}
}
$mysqli->close();
include("\mpdf\mpdf.php");
$mpdf=new mPDF('','A4');
$mpdf->simpleTables = true;
$mpdf->packTableData = true;
$keep_table_proportions = TRUE;
$mpdf->shrink_tables_to_fit=1;
$mpdf->WriteHTML($a);
$mpdf->Output('mytable.pdf', 'D');
exit;
?>
答案 0 :(得分:1)
在循环中编写下表关闭表,否则你将获得表中的表。
$a.='</table>';
这将100%为您服务。