1
2つのタイプのテーブルを作成する必要があります.1つはうまく動作するレジスタのように、2つ目は機能しないフォームのようです。ページの見出しが表示されますが、テーブルは表示されません。私は両方で同様のCSSとコーディングスタイルを使用しています。mpdf:縦型テーブルは問題ありませんが、横向きが表示されません
注:複数のレコードの場合は、各ページに1つの表を表示する必要があり、各表は1ページのみを消費する必要があります。以下は
は私のコードです:
<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;
?>
完璧なソリューションです。 – ITSagar