Actually, I'm having some issues with how to structure the code to run iterations if the absolute value is greater than 0.00005.
I have this code that computes the ratings and then inserts it into the database:
$converge_rs = $conn->Execute ( "SELECT * FROM team ORDER BY teamID DESC" ) or die ( $conn->ErrorMsg() );
while ( ! $converge_rs->EOF ) {
$team1_rs = $conn->Execute ( "SELECT * FROM team WHERE teamID = " . $converge_rs->Fields("teamID") . " LIMIT 1" ) or die ( $conn->ErrorMsg() );
$team1 = $team1_rs->Fields("teamID");
$team1_gp = $team1_rs->Fields("team_gp");
$team1_ww = $team1_rs->Fields("team_ww");
$team_old = $team1_rs->Fields("team_mpi");
$new_win = $team1_ww + 1;
$mpi = $new_win / $team1_gp;
$mpi_change = $mpi - $team_old;
$sql = "UPDATE team SET team_mpi = $mpi, team_mpiold = $team_old, team_mpichange = $mpi_change WHERE teamID = $team1";
$add_rating_rs = $conn->Execute($sql) or die ( $conn->ErrorMsg() );
$converge_rs->MoveNext(); }
This works excellent, right after that I have a query that checks to see how many, if any, of the entries have a $team_mpichange has an absolute value of > 0.0005.
$check_rs = $conn->Execute ( "SELECT COUNT(teamID) as check, teamID, team_mpi, team_mpiold, team_ww, team_gp, team_mpichange FROM team WHERE abs(team_mpichange) > 0.00005 GROUP BY teamID ORDER BY teamID DESC" ) or die ( $conn->ErrorMsg() );
if ( $check_rs->Fields("check") > 0 ) {
// RUN RATINGS AGAIN
} else {
// MOVE ON TO NEXT STEP
}
The problem I'm running into is I'm not sure how to set it so that in the // RUN RATINGS AGAIN to check when it is done and if one of the entries still has an absolute value of greater than 0.00005 it runs it again, but if not it moves on...