我有一个 php 文件(add_member.php)。我正在通过执行 SQL 查询来创建动态表。该文件的代码如下:
$sql = SELECT * FROM member_details WHERE lname='ABC';
$n = new data();
$res = $n -> querySend($sql);
?>
<table border="1" cellpadding="3" cellspacing="1">
<tr>
<td align="center"></td>
<td align="center">First Name</td>
<td align="center">Last Name</td>
<td align="center">Caste</td>
<td align="center">Residence address</td>
<td align="center">Education</td>
</tr>
<?php
$i=1;
while($row = mysql_fetch_array($res))
{
$member_no = $row['member_no'];
$total_member = "SELECT COUNT(*) AS total_member FROM family_member_details WHERE member_no =" .$member_no;
$total_res = $n -> querySend($total_member);
$row_total = mysql_fetch_array($total_res);
?>
<tr>
<td align="center" rowspan="<?php echo $row_total['total_member']+1;?>"><?php echo $i;?></td>
<td align="center"><?php echo $row['fname'];?></td>
<td align="center"><?php echo $row['lname'];?></td>
<td align="center"><?php echo $row['caste'];?></td>
<td align="center"><?php echo $row['residence_addr'];?></td>
<td align="center"><?php echo $row['education'];?></td>
</tr>
<?php
$family_sql = "SELECT * from family_member_details WHERE member_no = $member_no";
$family_res = $n -> querySend($family_sql);
while($row1 = mysql_fetch_array($family_res))
{
?>
<tr>
<td align="center"><?php echo $row1['name']?></td>
<td align="center"><?php echo $row1['name']?></td>
<td align="center"><?php echo $row1['name']?></td>
<td align="center"><?php echo $row1['name']?></td>
<td align="center"><?php echo $row1['name']?></td>
</tr>
<?php }
$i++;
} ?>
</table>
现在单击按钮后,我想在 PDF 文件中创建相同的表格。为此,我决定使用 TCPDF 库。但为此,我必须将 HTML 内容提供给 TCPDF 文件。现在我的问题是我应该如何从 PHP 文件中获取动态生成的表格的 HTML 并将此内容写入文本文件?任何人都可以在这方面帮助我吗?任何帮助将不胜感激。