gpt4 book ai didi

php - 它不显示 aantalkeermenu。有人知道为什么吗?

转载 作者:行者123 更新时间:2023-11-29 08:39:31 24 4
gpt4 key购买 nike

我的问题是为什么它不显示 $aantalkeermenu。但它显示的是查询中的另一个变量,任何人都可以帮助我吗?

这是我的查询:

$sql = "SELECT res.reserveringsnr, res.datum, menr.reserveringsnr, menr.menunr, SUM(menr.aantalkeermenu), men.menunr, men.menunaam, men.voorgerecht, men.hoofdgerecht, men.nagerecht  FROM reserveringen AS res
INNER JOIN menus_regel as menr
ON res.reserveringsnr = menr.reserveringsnr
INNER JOIN menus AS men
ON menr.menunr = men.menunr
WHERE res.datum = '".$invoerdatum."'
GROUP BY menr.menunr
";

这是在我的网页上显示的:

        $result = mysql_query($sql);

echo "<table>";
echo "<th>Aantal</th> <th> Menunaam </th><th> Voorgerecht </th> <th> Hoofdgerecht </th> <th> Nagerecht </th>";

while($row = mysql_fetch_assoc($result)) {
$datum = $row['datum'];
$aantalkeermenu = $row['aantalkeermenu'];
$menunr = $row['menunr'];
$menunaam = $row['menunaam'];
$voorgerecht = $row['voorgerecht'];
$hoofdgerecht = $row['hoofdgerecht'];
$nagerecht = $row['nagerecht'];
$aantalkeermenu = $row['aantalkeermenu'];


// open tr
echo "<tr id='$menunr' class='edit_tr'>";
echo "<td><span>$menunr</span></td>";
echo "<td><span>$aantalkeermenu</span></td>";
echo "<td><span>$menunaam</span></td>";
echo "<td><span>$voorgerecht</span></td>";
echo "<td><span>$hoofdgerecht</span></td>";
echo "<td><span>$nagerecht</span></td>";



echo "</tr>";
// close tr
}
echo "</table>";

最佳答案

当你

select ... SUM(menr.aantalkeermenu)

生成的列不会被称为aantalkeermenu。您需要明确命名该列,如下所示

select ... SUM(menr.aantalkeermenu) as aantalkeermenu

然后它将出现在结果行中该名称的下方。

关于php - 它不显示 aantalkeermenu。有人知道为什么吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14233338/

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