我有一个数据库/商店,这是我的简单查询:
$query_Recordset1 = "SELECT * FROM orders WHERE products = 30";
现在,我们想要实时了解当人们使用此产品时我们捐赠了多少钱。该产品的价格约为 30 美元(无关紧要),但我们每次购买都会捐赠 5 美元用于特定原因,并希望以美元显示总金额:
像这样:我们已经为这项事业或类似的事业捐赠了 755 美元!!
无论如何,这是我的 php.ini 文件。我们需要一个 $start 变量,它是我们在实现数据库和存储之前捐了多少钱..
在这里。我需要一点帮助才能解决这个问题:提前致谢:
<?php
$start = 20; // how much money we started with before the database
$limit = $start + $totalRows_Recordset1 + 5; // what we started with + the total number of rows that equal the product '30'
echo $limit;
?>
最佳答案
这是您要找的吗?
<?php
$query_Recordset1 = mysql_query("SELECT * FROM orders WHERE products = 30");
$num_rows = mysql_num_rows($query_Recordset1);
$start = 20; // how much money we started with before the database
$limit = $start + ($num_rows * 5); // what we started with + the total number of rows that equal the product '30'
echo $limit;
?>
关于php - 试图回应一个简单的货币数学语句,为每个 = "30"的记录集增加 5 美元的值(value)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3568755/