我有一个像这样的结果的查询。
SELECT check.c_id, check.voucher, check.payee, check.c_date, transact.atc_code, transact.value
FROM `check`
LEFT JOIN `transact`
ON check.c_id = transact.t_id
WHERE t_id='1' AND (atc_code LIKE '%72%' OR atc_code LIKE '%35%')
ORDER BY check.c_id
"c_id" "voucher" "payee" "c_date" "atc_code" "value" "1" "PDMK162953" "TOYOTA GLOBAL CITY, INC." "04/11/2016" "MK-GF-7202" "10338.44" "1" "PDMK162953" "TOYOTA GLOBAL CITY, INC." "04/11/2016" "MK-GF-3505" "206.77"
while($row = $result->fetch_assoc()) {
$c_id = $row['c_id'];
$voucher = $row['voucher'];
$payee = $row['payee'];
$c_date = strtotime($row['c_date']);
$atc_code = $row['atc_code'];
$income = $row['value'];
$tax = $row['value'];
}
我如何能够回应列'值'在html
中表的另一个单元格中表示第一个单元格10338.44和206.77答案 0 :(得分:2)
在查询中提及限制。
SELECT check.c_id, check.voucher, check.payee, check.c_date, transact.atc_code, transact.value
FROM `check`
LEFT JOIN `transact`
ON check.c_id = transact.t_id
WHERE t_id='1' AND (atc_code LIKE '%72%' OR atc_code LIKE '%35%')
ORDER BY check.c_id
LIMIT 2 // Add this
在一行和两列中显示记录:
<table border="1">
<tr>
<th>Tax 1</th>
<th>Tax 2</th>
<?php while($row = $result->fetch_assoc()) { ?>
<td>
<?php echo $row['value']; ?>
</td>
<?php } ?>
</tr>
</table>