gpt4 book ai didi

php - 使用 php 显示 mysql 的所有结果的问题

转载 作者:行者123 更新时间:2023-11-29 13:19:40 27 4
gpt4 key购买 nike

我使用此 SQL 查询从不同的表中获取结果

<?
$sql = "SELECT gtem.gname AS itmnme, gvendor.gname AS vendor, gtem.col AS qty
FROM gpopackageline
LEFT JOIN gpo ON gpo.gpoid = gpopackageline.gpoid
LEFT JOIN gtem ON gpopackageline.gtemid = gtem.gtemid
LEFT JOIN gvendor ON gitem.gvendorid = gvendor.gvendorid
WHERE gpopackageline.gpoid='".$sdo['swelid']."' ";
$row = dblib_get_row_list($sql);
?>
<td class="contents51" width="100%"><?=$row['itmnme']?> </td>
<td class="contents51" width="100%"><?=$row['vendor']?> </td>
<td class="contents51" width="100%"><?=$row['qty']?> </td>

问题是我只得到 1 个结果并且打印了第一个结果。当我在 phpmyadmin 中测试查询时,我得到了所有结果有谁可以帮忙解决这个问题吗谢谢您

最佳答案

您需要通过 whileforeach 循环结果 - 具体取决于您的逻辑。

例如

<?
$sql = "SELECT gtem.gname AS itmnme, gvendor.gname AS vendor, gtem.col AS qty
FROM gpopackageline
LEFT JOIN gpo ON gpo.gpoid = gpopackageline.gpoid
LEFT JOIN gtem ON gpopackageline.gtemid = gtem.gtemid
LEFT JOIN gvendor ON gitem.gvendorid = gvendor.gvendorid
WHERE gpopackageline.gpoid='".$sdo['swelid']."' ";
$getRows = dblib_get_row_list($sql); //Assuming this returns everything in an assoc array
foreach($getRows as $row) {
?>
<td class="contents51" width="100%"><?=$row['itmnme']?> </td>
<td class="contents51" width="100%"><?=$row['vendor']?> </td>
<td class="contents51" width="100%"><?=$row['qty']?> </td>
<?php
}
?>

关于php - 使用 php 显示 mysql 的所有结果的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21023588/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com