Page 1 of 1

Will this work??

Posted: Fri May 16, 2008 1:44 pm
by Todlerone
Hello all and TGIF (if it fits). I've just written some code I need for my baseball web site and I'm not close (ie, at home) to verify that it works. It is a loop to provide a teams "winning streak" output. I'm just curious if I'll have any problem with evaluating the $typestatus then reassign the same with a new value within the loop. I'm looking to output a type and value to it, example, W3, L2 or U3 (unbeaten in 3).

Code: Select all

 
for ($x=0;$x<$num_teams;$x++){
    $typenum=0;
    $v=sizeof($outcome[$x]);
    $typestatus=$outcome[$x][0];
    for ($y=0;$y<$v;$y++){
        $type=$outcome[$x][$y];
        if ($type=="W"){
            if ($typestatus=="W"){
                $typenum+=1;
            }elseif ($typestatus=="L"){
                $typestatus="W";
                $typenum=1;
            }elseif ($typestatus=="T"){
                $typestatus="U";
                $typenum+=1;
            }elseif ($typestatus=="U"){
                $typenum+=1;
            }
        }elseif ($type=="L"){
            if ($typestatus=="W"){
                $typestatus="L";
                $typenum=1;
            }elseif ($typestatus=="L"){
                $typenum+=1;
            }elseif ($typestatus=="T"){
                $typestatus="L";
                $typenum=1;
            }elseif ($typestatus=="U"){
                $typestatus="L";
                $typenum=1;
            }
        }elseif ($type=="T"){
            if ($typestatus=="W"){
                $typestatus="U";
                $typenum+=1;
            }elseif ($typestatus=="L"){
                $typestatus="U";
                $typenum=1;
            }elseif ($typestatus=="T"){
                $typestatus="U";
                $typenum+=1;
            }elseif ($typestatus=="U"){
                $typenum+=1;
            }
        }//end loop (if ($type=="W"))
    }//end loop (for ($y=0;$y<$v;$y++))     
}//end loop (for ($x=0;$x<$num_teams;$x++))
 
Thanks in advance. The code in theory works exatually how I need it to barring any problems with the code.

Re: Will this work??

Posted: Fri May 16, 2008 10:08 pm
by Todlerone
It works great....