Jump to content

Help with iteration


ameriblog

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.