在每页开头重复一个表格
我正在使用 PHP 动态生成报告。 TCPDF 用于生成 PDF。我想在每页的开头重复一个特定的表格。如何检测分页符并执行此操作?
$result_1 =db_query($sql_1);
while($row_1=db_fetch_array($result_1))
{
$table=
<tr><td width=100><b>Name</b></td>
<td width=50><b>No</b></td>
<td width=50><b>Date</td>
</tr>
<tr>
<td width=100>'.$row_1['name'].'</td>
<td width=50>'.$row_1['no'].'</td>
<td width=50>'.$row_1['date'].'</td>
</tr>
</table>';
}
我想在每页的开头显示该特定表格。该 while 循环中还有一些其他表。
I am using PHP to generate a report dynamically. TCPDF is used to generate a PDF. I want to repeat a particular table at the beginning of each page. How can I detect the page breaks and do this?
$result_1 =db_query($sql_1);
while($row_1=db_fetch_array($result_1))
{
$table=
<tr><td width=100><b>Name</b></td>
<td width=50><b>No</b></td>
<td width=50><b>Date</td>
</tr>
<tr>
<td width=100>'.$row_1['name'].'</td>
<td width=50>'.$row_1['no'].'</td>
<td width=50>'.$row_1['date'].'</td>
</tr>
</table>';
}
I want to show that particular table at the beginning of each page. There are few other tables also in that while loop.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您希望表格标题位于每个页面上,请使用
标记。
IE。
If you want the table header to be on each page you make use of the
<thead>
tag.ie.
您需要扩展 TCPDF 类并提供自定义函数来呈现标头,我相信该标头将包含在每个页面的顶部。
此处有一个涉及代码的示例,并加载更多 TCPDF 示例此处。您可以将该示例与此示例结合使用来完全满足您的需要。
希望有帮助
You need to extend the TCPDF class and provide a custom function to render your header, which I believe will then be included at the top of every page.
There's an example of the code involved here, and a load more TCPDF examples here. You could use that example in conjunction with this one to do exactly what you need.
Hope that helps
我建议将一个表的代码放在一个单独的 PHP 文件中,并在表输出的其余部分之前使用 Include() 。这样,当您包含该页面时,它将为其自身运行数据库查询。
I would suggest putting the code for the one table in a seperate PHP file and use Include() just before the rest of the table output. This way when you include the page, it will run the DB query for it's self.
我不太明白你的意思...但是如果你希望在所有网站页面中实现此代码...并在所有网站页面上查看此表,你可以执行以下 2 种方法
1-通过创建块和在页面顶部添加此块,如下所示
从 /admin/build/modules 启用 php 过滤器模块
从 admin 创建一个新块/build/block/add/ 并将输入格式更改为 php格式化并在此块内容中添加您的 php 代码
将此块添加到主题的顶部
2-只需在 page.tpl.php 主题文件的顶部添加代码,
我希望这会对您有所帮助
i don't understand you exactly...but if you want this code to be implemented in all your site pages....and see this table at all your site pages you can do tha following 2 ways
1-by creating block and add this block at the top of your pages like the following
enable php filter module from /admin/build/modules
create a new block from admin/build/block/add/ and change input format to php format and add your php code in this block content
add this block at the top of your theme
2- simply add your code at the top of page.tpl.php theme file
i hop that will help u