Weedpacket;11026759 wrote:Immediately upon reading the following line.
That's what I thought, too. But it no workee. Here's my code:
$Quest = "SELECT Techs.FirstName AS TechFirst,
Techs.LastName AS TechLast,
Techs.TechNum,
Supervisors.FirstName AS SupFirst,
Supervisors.LastName AS SupLast,
Supervisors.SupNum,
Systems.LongSystem,
Systems.SystemNum,
InTimeAppts.WorkDate,
InTimeAppts.NumAppts,
InTimeAppts.InTime,
InTimeAppts.Late,
InTimeAppts.Early,
InTimeAppts.NotStarted,
InTimeAppts.Cancelled
FROM Techs, Systems, Supervisors, InTimeAppts
WHERE Supervisors.SupNum = Techs.Supervisor AND Systems.SystemNum = Techs.SystemNum AND InTimeAppts.TechNum = Techs.TechNum AND InTimeAppts.WorkDate = '$WorkDate'
ORDER BY Systems.LongSystem ASC, Supervisors.SupNum ASC, Techs.TechNum ASC";
$stmt = $mysqli->prepare($Quest) or die('what is the matter here?');
$stmt->execute();
$SupResult = $stmt->get_result();
mysql_data_seek($SupResult, 1);
$row = $result->fetch_row();
while ($row = $SupResult->fetch_assoc())
{
$SupNum = $row["SupNum"];
$SupFirst = $row["SupFirst"];
$SupLast = $row["SupLast"];
$SystemNum = $row["SystemNum"];
$LongSystem = $row["LongSystem"];
$TechNum = $row["TechNum"];
$TechFirst = $row["TechFirst"];
$TechLast = $row["TechLast"];
$NumAppts = $row["NumAppts"];
$InTime = $row["InTime"];
$Late = $row["Late"];
$Early = $row["Early"];
$NotStarted = $row["NotStarted"];
$Cancelled = $row["Cancelled"];
((more code))
if ($PreviousSystemNum != $SystemNum) <---
{
$InTimePer = ceil($InTimeSub / $NumApptsSub * 1000) / 10;
$LatePer = ceil($LateSub / $NumApptsSub * 1000) / 10;
$EarlyPer = ceil($EarlySub / $NumApptsSub * 1000) / 10;
$NotStartedPer = ceil($NotStartedSub / $NumApptsSub * 1000) / 10;
$CancelledPer = ceil($CancelledSub / $NumApptsSub * 1000) / 10;
$NumApptsGrand = $NumApptsGrand + $NumApptsSub;
$InTimeGrand = $InTimeGrand + $InTimeSub;
$LateGrand = $LateGrand + $LateSub;
$EarlyGrand = $EarlyGrand + $EarlySub;
$NotStartedGrand = $NotStartedGrand + $NotStartedSub;
$CancelledGrand = $CancelledGrand + $CancelledSub;
echo $InTimeGrand . ' 11 ' . $LateGrand . ' 22 ' . $EarlyGrand . ' 33 ' . $NotStartedGrand . ' 44 ' . $CancelledGrand . '<br>';
$OutString[0] = 'Totals:';
$OutString[1] = '';
$OutString[2] = '';
$OutString[3] = '';
$OutString[4] =$NumApptsSub;
$OutString[5] =$InTimePer;
$OutString[6] =$LatePer;
$OutString[7] =$EarlyPer;
$OutString[8] =$NotStartedPer;
$OutString[9] =$CancelledPer;
fputcsv($fh, $OutString);
//even more code.
} // closes the 'if' statement
$PreviousSystemNum = $SystemNum
} // loops the 'while' statement
I can't get the proper words to describe what's happening, so let me draw you a picture of what's happening:
Get variables from database
While (variables)
{
System 7, TX -- Supervisor 1
-- Tech 1 Field A
-- Tech 4 Field A
-- Tech 7 Field A
System 7, TX -- Supervisor 2
-- Tech 22 Field A
System 7, TX -- Supervisor 3
-- Tech 12 Field A
-- Tech 14 Field A
System 12, OK -- Supervisor 4
-- Tech 32 Field A
[COLOR="#FF0000"]Sum of Field A for System 7 & first tech after SystemNum changes.[/COLOR]
-- Tech 17 Field A
System 9, TX -- Supervisor 5
-- Tech 32 Field A
[COLOR="#FF0000"]Sum of Field A for Last row of System7, and the first row of System 9 after SystemNum changes. [/COLOR]
-- Tech 24 Field A
}
I found this in the manual:
$Quest = large query here
$stmt = $mysqli->prepare($Quest) or die('hey you dope, what is the matter here?');
$stmt->execute();
$SupResult = $stmt->get_result();
while ($row = $SupResult->fetch_assoc())
{
mysql_data_seek($SupResult, 1); // <--- Line 186
$row = $SupResult->fetch_assoc();
$NextSystem = $row[0];
:: more code here::;
}
When I run the 'mysql_data_seek' statement, PHP returns this error:
Warning: mysql_data_seek() expects parameter 1 to be resource, object given in /Library/WebServer/Documents/DispatchReports/InTime.php on line 186
I am baffled. Doesn't look like a flock of ducks is coming my way. Great! There's only so many ways to cook a duck.