|
-
October 24th, 2008, 10:09 AM
#5
Re: php oracle OCIFetchInto while loop
Assuming the data is always in order (sorted per the SchoolID,) you wouldn't have to read ahead. If you're after the format you've printed, try this:
Code:
select statement here.... ordered by school code
statement execution here...
$total = 0;
$previousSCH = "";
while (OCIFetchInto($resultsA, &$resultsA_row, OCI_ASSOC+OCI_RETURN_NULLS))
{
$SCH = $resultsA_row['SCH'];
$Counter = $resultsA_row['COUNTER'];
$machine = $resultsA_row['COPIER'];
if ($previousSCH != $SCH)
{
// print total, then reset to 0;
$total = 0
$previousSCH = $SCH;
}
else
{
$total += $Counter;
}
Echo a table here
}
You may need to add an extra check in there for the first instance (ie, don't print a total row if it's the first time through the loop) but that should give you what you're after...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|