这是我的PHP代码:
viewPayments.php
选择贷款交易的发布日期:
while($row = mysql_fetch_array($select)){
echo "<option>".$row['rel_date']."</option>";
}
?>
</select>
<input class="button_search" type="submit" name="search_btn" value="Submit">
单击提交按钮时,所选日期将与该发布日期的付款一起显示:
<?php
if(isset($_POST['search_btn'])){
$date = $_POST['date'];
$query = mysql_query("SELECT m.MID,lt.advanced_interrest,
lt.due_date, lt.rel_date,lt.loan_amount,
p.pay_date,p.OR_no,p.pay_amount,
(lt.loan_amount - p.pay_amount) as balance,
DATE_ADD(lt.rel_date, lt.due_date) AS days
FROM members m ,loan_transaction lt , payment p WHERE m.MID = lt.MID AND lt.MID = p.MID AND m.MID = p.MID AND lt.rel_date = $date");
echo '
<tr>
<td>
<td> <input type="text" class="textbox" value ="Date Selected "> </td>
<td>
<input type="text" class="textbox" value ="'.$date.'">
</td>
</tr>';
?>
<tr id="tr">
<th id="sth">Payment Date</th>
<th id="sth">OR No</th>
<th id="sth">Amount </th>
<th id="sth">Current Balance</th>
<th id="sth">Penalty</th>
</tr>
<?php
while ($data =mysql_fetch_array($query)) {
echo '
<tr>
<td id="row">'.$data['pay_date'].'</td>
<td id="row">'.$data['OR_no'].'</td>
<td id="row">'.$data['pay_amount'].'</td>
<td id="row">'.$data['balance'].'</td>
</tr>';
}
这部分是对总付款的总结。
$q = mysql_query("SELECT SUM(payment.pay_amount) as sum
FROM payment,loan_transaction where loan_transaction.rel_date = $date");
$result = mysql_fetch_array($q);
if($result){
$sum = $result['sum'];
echo '
<tr>
<td id = "row"> Total Paid Amount </td>
<td> </td>
<td id ="row">'.$sum.'</td>
</tr>
';
这个总和的SQL代码在控制台中工作,但它不会显示在我的浏览器上。我的代码出了什么问题?
我如何更新当前余额?