首页 > 解决方案 > 将小数添加到脚本中的 PHP 输出

问题描述

我有一个非常简单的 PHP 脚本,我可以在其中添加费用,但是在显示时,小数点丢失了。

这是我当前从数据库中检索数据的代码:

        <table class="table table-bordered mg-b-0">
          <thead>
            <tr>
              <th>S.NO</th>
              <th>Expense Item</th>
              <th>Expense Cost</th>
              <th>Expense Date</th>
              <th>Cateogry</th>
              <th>Action</th>
            </tr>
          </thead>
            <?php
            $userid=$_SESSION['detsuid'];
            $ret=mysqli_query($con,"select * from tblexpense where UserId='$userid'");
            $cnt=1;
            while ($row=mysqli_fetch_array($ret)) {
            ?>
          <tbody>
            <tr>
              <td><?php echo $cnt;?></td>

              <td><?php  echo $row['ExpenseItem'];?></td>
              <td><?php  echo $row['ExpenseCost'];?></td>
              <td><?php  echo $row['ExpenseDate'];?></td>
              <td><?php  echo $row['ExpenseCat'];?></td>
              <td><a href="manage-expense.php?delid=<?php echo $row['ID'];?>">Delete</a>
            </tr>
            <?php $cnt=$cnt+1;}?>
          </tbody>
        </table>

这里是我当前的输出:

    <table class="table table-bordered mg-b-0">
      <thead>
        <tr>
          <th>S.NO</th>
          <th>Expense Item</th>
          <th>Expense Cost</th>
          <th>Expense Date</th>
          <th>Cateogry</th>
          <th>Action</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>1</td>          
          <td>Test Expense</td>
          <td>4357745</td>
          <td>2020-02-13</td>
          <td>Office Supplies</td>
          <td><a href="manage-expense.php?delid=59">Delete</a>
        </td></tr>        
      </tbody>
    </table>

如何更改我的代码以使用小数正确显示价格值?一些专家的帮助将不胜感激

标签: php

解决方案


推荐阅读