gpt4 book ai didi

php - 将本地主机 PHP 转换为 PDF

转载 作者:行者123 更新时间:2023-11-29 17:10:31 25 4
gpt4 key购买 nike

我目前设置了一个主页,其中包含用于获取表行数据的数组查询,我已经测试了 PhpToPDF 和 TCPDF,但我遇到了我不知道该怎么做的问题,我的数组限制我发送数据的选项,但数组依赖于用户登录时,他们的登录用户名为查询提供从数据库获取所需的信息标准。我还遇到了在本地主机上托管网页的问题。任何人都可以演示如何在单击创建 PDF 时将表格转换为 pdf 文档吗?预置免费的解决方案

$query = "select * from orders where userid= ' $userid' order by orderid";

$result = mysqli_query($db,$query);
if ($result){
while ($rows = mysqli_fetch_array($result))
{
?>

<tr>
<td> <?php echo $rows[4]; ?> </td>
<td> <?php echo $rows[0]; ?> </td>
<td> <?php echo $rows[1]; ?> </td>
<td> <?php echo $rows[2]; ?> </td>
<td> <?php echo $rows[3]; ?> </td>
<td>
<a href ="deleteorderhomepage.php?receiptid=<?php echo $rows[3]?>&orderid=<?php echo $rows[0]?>">Delete </a>
</td>
</tr>
<?php
if(isset($_POST["create_pdf"])) { }
}
}
?

</table>
</br>
<input type="submit" name="create_pdf" value="Create PDF" />
</div>
</div>
</body>
</html>

最佳答案

这个非常简单的插件:Datatables

<html>
<head>
<title>Datatables Exmple by LahiruTM</title>

<link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet"/>
<link href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css" rel="stylesheet"/>


<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"></script>


<script>
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
{ extend:'copy', attr: { id: 'allan' } }, 'csv', 'excel', 'pdf', 'print'
]
} );
} );
</script>
</head>
<body>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008/11/28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012/12/02</td>
<td>$372,000</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
</body>
</html>

关于php - 将本地主机 PHP 转换为 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51905023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com