我需要在 Dom PDF 的 2 个不同页面上使用 PHP for 循环创建一个 table?
I need to create a table on 2 different Page on Dom PDF Using PHP for loop?
我尝试使用 DOM PDF 创建 Table,但不确定我遇到语法标记错误错误,任何人都可以帮助我解决这个问题。
下面是我在 $html 变量中使用的 for 循环代码。
$html = "<html></head>
<body>
<main>
<table>
<tr>
<th '>Year</th>
<th '>Age</th>
<th align='center'>Saving</th>
<th >Expenses</th>
</tr>"
for ($year=0; $year < 15; $year++) {
$html.=
'<tr class="table_row">
<td align="center">'.$year.'</td>
<td align="center">'.$table_data['age'][$year].'</td>
<td align="center">'.$table_data['savings'][$year].'</td>
<td align="center">'.$table_data['expenses'][$year].'</td>
</tr>';
}
" </table>
</main>
</body>
</html>";
您需要创建两个 pdf 并在两个 pdf 上使用 2 个 foreach 循环来获取您需要的数据。
试试这个解决方案。它对我有用。
我尝试使用 DOM PDF 创建 Table,但不确定我遇到语法标记错误错误,任何人都可以帮助我解决这个问题。
下面是我在 $html 变量中使用的 for 循环代码。
$html = "<html></head>
<body>
<main>
<table>
<tr>
<th '>Year</th>
<th '>Age</th>
<th align='center'>Saving</th>
<th >Expenses</th>
</tr>"
for ($year=0; $year < 15; $year++) {
$html.=
'<tr class="table_row">
<td align="center">'.$year.'</td>
<td align="center">'.$table_data['age'][$year].'</td>
<td align="center">'.$table_data['savings'][$year].'</td>
<td align="center">'.$table_data['expenses'][$year].'</td>
</tr>';
}
" </table>
</main>
</body>
</html>";
您需要创建两个 pdf 并在两个 pdf 上使用 2 个 foreach 循环来获取您需要的数据。
试试这个解决方案。它对我有用。