我想在 PDF 文件中显示结果。现在的问题是 PDF 文件只能捕获 while 循环的第一行。row[0]['rates']
第一行和row[1]['rates']
第二行有类似的东西吗?所以我可以只取一次并row[0]['rates']
显示row[1]['rates']
...
创建 PDF:
<?php
session_start();
if( empty( $_POST['compare'] ) )
include"connect_to_mysql.php";
$packages = mysql_query("SELECT*FROM package_creation WHERE id IN (". implode(',', $_POST['compare']) ." ) LIMIT 4");
while($row=mysql_fetch_array($packages)){
$compare ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Compare Packages</title>
<style type="text/css">
.print_title{
font-family:Arial, Helvetica, sans-serif;
font-size:20px;
font-weight:bold;
color:#000;
}
.print_text{
font-family:Arial, Helvetica, sans-serif;
font-size:10px;
color:#000000;
}
.print_bold{
font-family:Arial, Helvetica, sans-serif;
font-size:10px;
color:#000000;
font-weight:bold;
}
.print_footer{
font-family:Arial, Helvetica, sans-serif;
font-size:9px;
color:#000000;
}
.print_big{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
color:#000000;
font-weight:bold;
}
body{
margin:0px;
}
table td{
height:1px;
}
</style>
</head>
<body>
<table class="print_text" align="left">
<tr>
<td width="200px" class="print_bold" align="right">Package</td><td width="100px" class="print_bold" align="center">Package 1</td><td width="100px" class="print_bold" align="center">Package 2</td><td width="100px" class="print_bold" align="center">Package 3</td><td width="100px" class="print_bold" align="center">Package 4</td>
</tr>
<tr>
<td class="print_bold" align="right">Bank Code:</td><td width="100px" align="center">'.$row['bank_name'].'</td><td width="100px" align="center">display 2nd bank</td><td width="100px" align="center">display 3rd bank</td><td width="100px" align="center">display 4th bank</td>
</tr>
</table>
</body>
</html>';
}
include_once('dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->load_html($compare);
$dompdf->render();
$dompdf->stream('Compare_Packages.pdf');
?>