Calculations in For Loop
Posted: Sun Jul 30, 2006 6:41 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hey Gang,
I'm having trouble grasping calculations in my loop.
Here's the loop, I wish to calculate total and print to grandtotal.
Can someone point me to an example of calcs in a for loop?
ta, WilCode: Select all
$query = "SELECT * FROM statements WHERE client_id = '".$id."'";
$dbh->query($query);
print "<table width=500><tr><td width=50>Total</td></tr>";
for ( $i = 0; $i < $dbh->numrows; $i++ ) {
$dbh->get();
$id = $dbh->rowdata[0];
$client_id = $dbh->rowdata[1];
$total = $dbh->rowdata[8];
print "<tr><td>$id</td><td>**$total**</td></tr>";
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]