php - 如何在表格中自动显示计数数据累积和残差数据?
问题描述
我有一个问题,我在显示累积和剩余时使用直线法。我想知道如何使用 php 来自动计算。
这是用于提交数据的表格:
<h1>Penyusutan</h1>
<table>
<form action="deprecalc.php" method="post">
<label>Nominal : </label>
<input type="text" name="nominal"><br>
<label>Lama Depresiasi : </label>
<input type="text" name="depresiasi"><br>
<label>Awal : </label>
<input type="text" name="awal"><br>
<label>Akhir : </label>
<input type="text" name="akhir"><br>
<label>Residu Aset : </label>
<input type="text" name="residu"><br>
<input type="submit">
</form>
</table>
这是php处理:
<?php
$nominal = $_POST['nominal'];
$depresiasi = $_POST['depresiasi'];
$awal = $_POST['awal'];
$akhir = $_POST['akhir'];
$residu = $_POST['residu'];
?>
<h2>Nominal : <?php echo $nominal;?></h2></br>
<h2>Despresiasi : <?php echo $depresiasi;?></h2></br>
<table id="values">
<tr>
<th>Nominal</th>
<th>Tahun</th>
<th>Umur</th>
<th>Akumulasi</th>
<th>Residu</th>
</tr>
<?php
$no = 1;
$years = date('Y');
for ($i=0; $i < $depresiasi ; $i++) {
$rumus = ($nominal - $residu) / $depresiasi;
$rumusResidu = ($nominal - $rumus);
?>
<tr>
<?php echo "<td>".$nominal."</td>" ?>
<?php echo "<td>".$years++."</td>" ?>
<?php echo "<td>".$no++."</td>" ?>
<?php echo "<td>".$rumus."</td>" ?>
<?php echo "<td>".$rumusResidu."</td>" ?>
</tr>
<?php } ?>
</table>
我所做的结果是:
附上预期的结果:我该如何实现?谢谢
解决方案
推荐阅读
- python - 从 Google Drive 下载大量小文件
- r - 错误:“tidyverse”的包或命名空间加载失败:“命名空间:dplyr”未导出对象“重定位”
- python - 在大量网站上搜索关键字
- reactjs - 如何使用样式化组件更改 antd 轮播点的形状和颜色
- fortran - 如何自动将间隔数加倍
- javascript - 如何防止打字稿将动态导入转换为require()?
- xss - 通过 CSS 选择器的 XSS
- javascript - 如何在 React 中下载编码资产(任何类型的文件)?
- angularjs - AngularJS 1.4 掩码输入电话号码问题
- javascript - 在 Vue.js 中启用和禁用提交按钮