ameriblog Posted August 25, 2007 Share Posted August 25, 2007 I have a rating system to rate sports teams in PHP. One issue I'm having is how to have my IF statement re-run the ratings based on the results. The code works perfectly fine and is like this: // START CHECKING CONVERGENCE $check_rs = $conn->Execute ( "SELECT * FROM team WHERE team_year = " . $_GET['year'] . " ORDER BY team_mpichange DESC" ) or die ( $conn->ErrorMsg() ); $change = $check_rs->Fields("team_mpichange"); $change = abs($change); if ( $change > 0.00005 ) { // RUN WHOLE RATING SYSTEM OVER } else { // SKIP TO NEXT STEP } // END CHECKING CONVERGENCE What I am trying to accomplish is if $change is greater than 0.00005 I want it to run the ratings again and then check the convergence again. If $change is less than 0.00005 then just skip on to the next step. My code is about 400+ lines long, the ratings start on line 124, I don't know if I can use that or if I can set a mark to go back and run that again. Quote Link to comment https://forums.phpfreaks.com/topic/66669-help-with-iteration/ Share on other sites More sharing options...
Barand Posted August 25, 2007 Share Posted August 25, 2007 try <?php do { //RATING SYSTEM HERE $check_rs = $conn->Execute ( "SELECT * FROM team WHERE team_year = " . $_GET['year'] . " ORDER BY team_mpichange DESC" ) or die ( $conn->ErrorMsg() ); $change = $check_rs->Fields("team_mpichange"); $change = abs($change); } while ( $change > 0.00005 ); // NEXT STEP HERE ?> Quote Link to comment https://forums.phpfreaks.com/topic/66669-help-with-iteration/#findComment-334029 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.