I have a search feature that displays records from a database based on date range search. What I want to do is echo the total sum of the "refund_amount" column that is displayed after the date range search. I know how to get the total sum from all the records from the database. I need to echo only the sum of the "refund_amount" column that is being displayed after the date range search. Any help is greatly appreciated.
Here is my code:
<?php
include('includes/connect.php');
if (isset($_GET["status"])) { $status = $_GET["status"]; } else { $status=0; };
if (isset($_GET["d1"])) { $d1 = $_GET["d1"]; } else { $d1=0; };
if (isset($_GET["d2"])) { $d2 = $_GET["d2"]; } else { $d2=0; };
$result = $connect->prepare("SELECT * FROM rma_list WHERE refund_date BETWEEN :a AND :b");
$result->bindParam(':a', $d1);
$result->bindParam(':b', $d2);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td><?php echo $row['rma_id']; ?></td>
<td><?php echo $row['order_date']; ?></td>
<td><?php echo $row['rma_request_date']; ?></td>
<td><?php echo $row['rma_number']; ?></td>
<td><?php echo $row['order_number']; ?></td>
<td><?php echo $row['so_number']; ?></td>
<td><?php echo $row['vendor_name']; ?></td>
<td><?php echo $row['vendor_ra']; ?></td>
<td><?php echo $row['customer_name']; ?></td>
<td><?php echo $row['credit_memo_number']; ?></td>
<td><?php echo $row['refund_amount']; ?></td>
<td><?php echo $row['refund_date']; ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php
}
?>