gpt4 book ai didi

php - MySQLi 列总和适用于一个查询,但不适用于另一查询

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

我正在尝试对一列的总值(value)求和......

我让它可以对其他列进行求和,但该列不会求和,并且我没有得到回显的值。

任何人都可以提出任何建议,为什么列返回的格式与利润完全相同(小数 5,2)

PHP - 工作

 <div class="col-md-2 col-md-2-2">
<div class="card mt-5">
<div class-title>
<h3 role="button" class="bg-secondary text-white text-
center py-3">Stake Placed<br></h3>
</div>
<div class="card-body">
<table class='table table-bordered'>
<?php

$connection = mysqli_connect("******", "******",
"******", "******");
if (!$connection) {
die("Database connection failed: " . mysqli_connect_error());
}

$Date = '2019-03-11';

$ssql="SELECT sum(stakePlaced) as total FROM bets WHERE betDate = '$Date'";


$sresult = mysqli_query($connection, $ssql);

while ($srow = mysqli_fetch_assoc($sresult))
{
echo "<tr>";
echo "<td class='text-center'>£".$srow['total'] . "</td>";
echo "</tr>";
}

mysqli_close($connection);
?>
</table>
</div>


</div>
</div>

PHP - 不工作

            <div class="col-md-2 col-md-2-2">
<div class="card mt-5">
<div class-title>
<h3 role="button" class="bg-secondary text-white text-
center py-3">Actual Return<br></h3>
</div>
<div class="card-body">
<table class='table table-bordered'>
<?php

$connection = mysqli_connect("******", "******",
"******", "******");
if (!$connection) {
die("Database connection failed: " . mysqli_connect_error());
}

$Date = '2019-03-11';

$test = "SELECT sum(return) as total FROM bets WHERE betDate = '$Date'";

$testr = mysqli_query($connection, $test);

while ($testrow = mysqli_fetch_assoc($testr))

{
echo "<tr>";
echo "<td class='text-center'>£".$testrow['total'] . "</td>";
echo "</tr>";
}

mysqli_close($connection);
?>
</table>

result screenshot table screenshot

最佳答案

return是mysql中的保留关键字。更改列名称,或者在使用该列名称时应使用刻度

sum(`return`) 

关于php - MySQLi 列总和适用于一个查询,但不适用于另一查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55063396/

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