bobo
October 24th, 2008, 08:41 AM
hello
In a nut shell I need to know if there is a way to read the next value of the OCIFetchInto array before it is printed. If this is not clear enough read on.
I have an intranet page for a school board that fetches all the photocopiers in the schools and keeps a score of the copies they used so that its easy to keep track of the number of copies we need to be charged for.
It an oracle/php application and I have your usual OCIFetchInto listing all the info correctly.
select statement here.... ordered by school code
statement execution here...
while (OCIFetchInto($resultsA, &$resultsA_row, OCI_ASSOC+OCI_RETURN_NULLS)) {
$SCH = $resultsA_row['SCH'];
$Counter = $resultsA_row['COUNTER'];
$machine = $resultsA_row['COPIER'];
Echo a table here
}
The code above was abriviated because there really no use to post all of it because what I need to do is to read the next field that is coming up before the while loop prints it.
My real code prints out a table, something like this:
------------------------------------------------------
photocopier_name | School Code | counter
-------------------------------------------------------
XeroxA | SCH1 | 123
XeroxB | SCH1 | 123
XeroxC | SCH1 | 123
XeroxD | SCH2 | 456
XeroxE | SCH2 | 456
XeroxF | SCH2 | 456
so here there's 6 machines at 2 different schools
my problem is I want to get the total of the all the counters (3 copiers in this example per school) . so SCH1 = 369. I know how to do that but I want to insert a table row at the end of each school code with the total per school.
like this:
XeroxA | SCH1 | 123
XeroxB | SCH1 | 123
XeroxC | SCH1 | 123
--------------------------
369
-------------------------
XeroxD | SCH2 | 456
XeroxE | SCH2 | 456
XeroxF | SCH2 | 456
--------------------------
1368
--------------------------
and so on...(38 schools)
What I need here is a logic or maybe a function name if it exists because I have no clue how to say to the loop... "if your changing school code apply a new table row" Is there a way I can read the next value in the array and say if the next school code is same do nothing... if the next school code is different apply my total count function.
[sorry about the long post i just to be as clear as possible]
In a nut shell I need to know if there is a way to read the next value of the OCIFetchInto array before it is printed. If this is not clear enough read on.
I have an intranet page for a school board that fetches all the photocopiers in the schools and keeps a score of the copies they used so that its easy to keep track of the number of copies we need to be charged for.
It an oracle/php application and I have your usual OCIFetchInto listing all the info correctly.
select statement here.... ordered by school code
statement execution here...
while (OCIFetchInto($resultsA, &$resultsA_row, OCI_ASSOC+OCI_RETURN_NULLS)) {
$SCH = $resultsA_row['SCH'];
$Counter = $resultsA_row['COUNTER'];
$machine = $resultsA_row['COPIER'];
Echo a table here
}
The code above was abriviated because there really no use to post all of it because what I need to do is to read the next field that is coming up before the while loop prints it.
My real code prints out a table, something like this:
------------------------------------------------------
photocopier_name | School Code | counter
-------------------------------------------------------
XeroxA | SCH1 | 123
XeroxB | SCH1 | 123
XeroxC | SCH1 | 123
XeroxD | SCH2 | 456
XeroxE | SCH2 | 456
XeroxF | SCH2 | 456
so here there's 6 machines at 2 different schools
my problem is I want to get the total of the all the counters (3 copiers in this example per school) . so SCH1 = 369. I know how to do that but I want to insert a table row at the end of each school code with the total per school.
like this:
XeroxA | SCH1 | 123
XeroxB | SCH1 | 123
XeroxC | SCH1 | 123
--------------------------
369
-------------------------
XeroxD | SCH2 | 456
XeroxE | SCH2 | 456
XeroxF | SCH2 | 456
--------------------------
1368
--------------------------
and so on...(38 schools)
What I need here is a logic or maybe a function name if it exists because I have no clue how to say to the loop... "if your changing school code apply a new table row" Is there a way I can read the next value in the array and say if the next school code is same do nothing... if the next school code is different apply my total count function.
[sorry about the long post i just to be as clear as possible]