gpt4 book ai didi

php - 使用 PHP 从 MySQL 表进行计算

转载 作者:行者123 更新时间:2023-11-30 01:20:41 25 4
gpt4 key购买 nike

我是PHP新手并且我想知道如何创建一个计算百分比的 sql 语句使用 PHP 从我的数据库表中获取。

示例是:我的数据库中的值为 10000,我想获取其 0.50%

对于这样的说法我们深表歉意。我不知道技术术语。希望你能帮我。谢谢!

我不知道这是否正确。敬请谅解。 :D

这是我的代码:

<?
$result = mysql_query("SELECT * FROM tbl_payment where amount");

$num_total = ($amount / $num_percent) * 100;
echo $num_total;
?>

最佳答案

sql 语法错误

$result   = mysql_query("SELECT * FROM tbl_payment where amount=10000");
while($row=mysql_fetch_array($result)){
$num_total = ($['your column name for computing %'] / $num_percent) * 100;
echo $num_total;
}

关于php - 使用 PHP 从 MySQL 表进行计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18580310/

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