PHP、MYSQL只获取结果数组的第一行和第二行


PHP, MYSQL get 1st and second row only of result array

我有一个查询结果如下。

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"凭单"收款人"c_date"atc_code"值"1"PDMK162953"丰田环球城有限公司"2016年11月4日"MK-GF-7202"10338.44"1"PDMK162953"丰田环球城有限公司"2016年11月4日"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'];
}

如何将列"value"回显到html 中表的第一个单元格10338.44和另一个单元格中的206.77

只需在查询中提及限制即可。

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>