将2个表格行相乘即可得出总数

时间:2018-12-04 16:18:35

标签: php html mysqli

我正在尝试将2个表格行相乘,但总价未显示在表格中。这是我的代码:

$result = mysqli_query($connect,"SELECT * FROM `inventory_item` LIMIT $offset, $total_records_per_page");
while ($row = mysqli_fetch_array($result))
        {

            $item_name = $row ['item_name'];
            $total_price = $row['price'] * $row['quantity'];
            $total_price = $row['total_price'];
            echo '<tr><td>'.$row['id']. '</td><td>'.$row['item_name']. '</td><td>'.$row['description']. '</td><td>'.$row['unit'].'</td>
            <td>'.$row['quantity']. '</td><td>'.'P'. ''.number_format((float)$row['price'],2,'.',''). '</td>
            <td>'.$row['total_price'].'</td><td>'.$row['assigned_officer']. '</td><td>'.$row['claimdate']. '</td>
            <td>'.$row['status'].'</td>
            <td><a href="inventory_statusEditRecordsFinal1.php?CO='.$item_name.'" title="Click to edit records" class="btn btn-primary"/> Edit  </a></td>
            <td><a href="inventory_deletestatusFinal.php?item_name='.$item_name.'" title="Click to delete records" class="btn btn-primary" onclick="return ConfirmDelete()"/> Delete  </a></td>

            </tr>';


        }

1 个答案:

答案 0 :(得分:1)

您刚刚切换了变量:

 $row['total_price'] = $total_price;

代替

$total_price = $row['total_price'];