我想在PDF文件中顯示結果。現在的問題是PDF文件只能捕獲while循環的第一行。第一行有row[0]['rates']
,第二行有row[1]['rates']
?所以我只能取一次,顯示row[0]['rates']
和row[1]['rates']
...PHP mysql在一個目標中顯示4個結果
創建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');
?>