mt006 wrote:
> I am using PHP with a mySQL database. One of my pages
display results from
> the database in a table with repeat region on it. Is
there a way of totalling
> fields on the page.
Yes, it's quite easy. Create a variable to hold the total and
add the
value of each field. Let's say your repeat region looks like
this:
<?php do { ?>
<tr>
<td>Amount</td>
<td><?php echo $row_recordsetName['amount'];
?></td>
</tr>
<?php } while ($row_recordsetName =
mysql_fetch_assoc($recordsetName)); ?>
Change it like this:
<?php $total = 0;
<?php do { ?>
<tr>
<td>Amount</td>
<td><?php echo $row_recordsetName['amount'];
$total += $row_recordsetName['amount'];?></td>
</tr>
<?php } while ($row_recordsetName =
mysql_fetch_assoc($recordsetName)); ?>
<tr>
<td>Total</td>
<td><?php echo $total; ?></td>
</tr>
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/