0

数値mysqlの結果値を丸める方法

$earnedbasic=$runrows['salary']/$runrows['days']*$runrows['countdaystotal'];

例: 給料を日数で割り、労働日数を掛ける

150 salary
29 days
30 workingdays

150/29x30=155.17241

結果がそのようなものである場合、値の例を155.17241に丸めたいのですが、155.173のみが必要です。この問題を解決するのを手伝ってください

<?php



       while ($runrows = mysql_fetch_assoc($run))
       {

        //get data
       $workerid = $runrows['workerid'];
       $keywords = $runrows['keywords'];
       $salary =  $runrows['salary'];
       $days = $runrows['days'];
       $countdaystotal = $runrows['countdaystotal'];
       $earnedbasic=$runrows['salary']/$runrows['days']*$runrows['countdaystotal'];


 echo "<table class='sortable' border='1' cellpadding='10'>";
        echo "<tr> <th>ID</th> <th>Name</th><th>Basic</th><th>Days</th> <th>Earned Basic</th><th>Total Salary</th></tr>";


     echo "<tr width='50%' onmouseover=\"this.style.backgroundColor='#999999';\" onmouseout=\"this.style.backgroundColor='#d4e3e5';\"><td width='20%'><a href=\"detail.php?id=$id\" class=\"style1\">$workerid</a></td>
     <td width='20%'>$keywords</td>
    <td width='20%'>$salary</td>
     <td width='20%'>$countdaystotal</td>
     <td width='20%'>$earnedbasic</td></tr>";


echo "</table>";
       }

     }



    }


?>
4

2 に答える 2

2

えっと…round($earnedbasic,3)やるべきです。

于 2013-01-29T18:43:38.150 に答える
0
<td width='20%'>".round($earnedbasic, 3)."</td>

また

$earnedbasic=round($runrows['salary']/$runrows['days']*$runrows['countdaystotal'],3);
于 2013-01-29T18:45:58.083 に答える