我有5个来自数据库的php变量,使用这些变量我想计算一个付款计划表。这是我的loan_calc.php代码。此变量成功回显其值,但未构建表。非常感谢你。
<p>
<?php require_once('include_header.php'); ?>
<?php
$sql='SELECT * FROM tbl_loan_application where application_id= 1563256222';
$result = mysql_query($sql, $conn) or die(mysql_error());
$row = mysql_fetch_assoc($result);
// echo $row['application_id'];
// echo "<br />";
// echo $row['number_of_rentel'];
// echo "<br />";
// echo $row['loan_amount'];
// echo "<br />";
// echo $row['effective_rate'];
// echo "<br />";
// echo $row['accepted_amount'];
// echo "<br />";
// echo $row['repayment'];
$npy=$row['number_of_rentel'];
$apr=$row['effective_rate'];
$amount=$row['accepted_amount'];
$Repayment=$row['repayment'];
$payment=$row['payment'];
echo "<table class='table table-striped table-hover' border='1' cellspacing='1' cellpadding='5'>";
echo "<tr class='success'><td align='center'>Payment<br>Number</td><td align='center'>Payment<br>Amount</td><td align='center'>Interest</td><td align='center'>Principle</td><td align='center'>Balance</td></tr>";
//$amount= eval($amount);
for($i=1; $i<=$Repayment*$npy;$i++){
$tbldata='<td>';
$interest=$amount*$apr/$npy/100;
$amount+=$interest;
$principle=$payment-$interest;
$amount-= $payment;
echo'<tr>'+$tbldata+$i+':</td>'+$tbldata+round($payment)+'</td>'+$tbldata+round($interest)+'</td>'+$tbldata+round($principle)+'</td>'+$tbldata+round($amount)+'</td></tr>';
}
echo'</table>';
?>
答案 0 :(得分:0)
尝试在echo中使用 .
(点)代替 +
,如以下代码
echo'<tr>'.$tbldata.$i.':</td>'.$tbldata.round($payment).'</td>'.$tbldata.round($interest).'</td>'.$tbldata.round($principle).'</td>'.$tbldata.round($amount).'</td></tr>';