php mysqli获取数据并将两个变量除以固定(2)/两位小数

php mysqli获取数据并将两个变量除以固定(2)/两位小数,php,Php,我已经能够从mysqli查询中划分两个变量。。。如何将数字除以两位小数/toFIxed2 php 因此,bet_count/win_count按预期工作……我只需要整数,例如2.371237234到小数点后两位2.37,您可以尝试使用以下函数: <?php $Date = $_GET['date']; $Win = 'Win'; $testsql = " SELECT count(*) AS bet_count, SUM(IF(result ='$Win'

我已经能够从mysqli查询中划分两个变量。。。如何将数字除以两位小数/toFIxed2

php

因此,bet_count/win_count按预期工作……我只需要整数,例如2.371237234到小数点后两位2.37,您可以尝试使用以下函数:

<?php
$Date = $_GET['date'];
$Win = 'Win';

$testsql = "
   SELECT 
      count(*) AS bet_count,
      SUM(IF(result ='$Win', 1, 0)) AS win_count
   FROM bets WHERE betDate = '$Date' GROUP BY betDate 
";

$testresult = mysqli_query($connection, $testsql);

while ($testrow = mysqli_fetch_assoc($testresult)) { 
    echo "<tr>";
    $value = number_format($testrow['bet_count']/$testrow['win_count'], 2, '.', '');
    echo "<td class='text-center'>".$value."</td>";
    echo "</tr>";
}

哇…这很简单,谢谢,当我能回答的时候,我会记下一个答案:@GeorgeRichardson:别忘了接受正确的答案,这将有助于未来的访客。
<?php
$Date = $_GET['date'];
$Win = 'Win';

$testsql = "
   SELECT 
      count(*) AS bet_count,
      SUM(IF(result ='$Win', 1, 0)) AS win_count
   FROM bets WHERE betDate = '$Date' GROUP BY betDate 
";

$testresult = mysqli_query($connection, $testsql);

while ($testrow = mysqli_fetch_assoc($testresult)) { 
    echo "<tr>";
    $value = number_format($testrow['bet_count']/$testrow['win_count'], 2, '.', '');
    echo "<td class='text-center'>".$value."</td>";
    echo "</tr>";
}