【发布时间】:2015-12-09 10:27:16
【问题描述】:
我可以在对两个或更多表运行查询后打印一组数据吗?
这是来自我的两个查询表:
第一个查询
$query = mysql_query("SELECT id, BuyerName,BuyerEmail,BuyerAddress,TransactionID, ItemAmount,DateTime FROM `order` WHERE YEAR(DateTime)= '$Year'AND MONTH(DateTime) = '$Month' LIMIT $start, $per_page") or die(mysql_error());第二次查询
$querydetail = mysql_query("SELECT * FROM orderlist WHERE TransactionID = '$f4'");
是否可以通过使用 table 以在 php 中设置的方式打印它?
这就是我以表格格式显示数据的方式。有没有办法将此输出直接导入 Microsoft Word 或 A4 纸格式的文件?
<?php
while($row = mysql_fetch_array($query))
{
$f1 = $row['BuyerName'];
$f2 = $row['BuyerEmail'];
$f3 = $row['BuyerAddress'];
$f4 = $row['TransactionID'];
$f5 = $row['ItemAmount'];
$f6 = $row['DateTime'];
?>
<table class="table">
<tr>
<th>Nama Pelanggan</th>
<th>Email Pelanggan</th>
<th>Alamat Pelanggan</th>
<th>ID Transaksi</th>
<th>Harga</th>
<th>Tarikh</th>
<tr>
<td><?php echo $f1 ?></td>
<td><?php echo $f2 ?></td>
<td><?php echo $f3 ?></td>
<td><?php echo $f4 ?></td>
<td><?php echo $f5 ?></td>
<td><?php echo $f6 ?></td>
</tr>
<table class="table">
<tr>
<th>Nama Barang</th>
<th>Kod Barang</th>
<th>Kuantiti</th>
</tr>
<?php
$querydetail = mysql_query("SELECT * FROM orderlist WHERE TransactionID = '$f4'");
while($rows = mysql_fetch_array($querydetail))
{
$fd1 = $rows['ItemName'];
$fd2 = $rows['ItemNumber'];
$fd3 = $rows['ItemQTY'];
?>
<tr>
<td><?php echo $fd1 ?></td>
<td><?php echo $fd2 ?></td>
<td><?php echo $fd3 ?></td>
</tr>
【问题讨论】:
-
您确定没有收到任何错误/意外结果吗?因为我看到了其中一些。
-
像魅力一样工作:D只需要添加打印功能
-
所以
<td><?php echo $f1 ?></td>不需要在;后面加上$f1。 -
好吧,刚刚在阅读您的评论后再次尝试,仍然很好。