#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    I'm trying to design a script that generates NBA standings from inputted scores. In addition to win/loss records, I want to keep track of division and conference records. So I have several arrays that include the teams that fall under each catetgory:

    @teams - All teams
    @east/@west - By conference
    @pacific, @midwest, @central, @atlantic - By division

    How can I say "if Team A is in @pacific and Team B is in @pacific and Team A's score is higher than Team B, then add 1 to Team A's division wins and add 1 to Team B's division losses"?

    Any help would be greatly appreciated. Thanks!

    Mike
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Cape Town, WP, South Africa
    Posts
    39
    Rep Power
    15
    Hi there

    Interesting so I gave it a bash, it should work in theory

    There are two ways first using a data base with associative arrays, and then just with arrays

    Try making the divisions Associative arrays or hasehes
    so that you can pull the value team A out of the array

    #these are from the input form

    $score = q->param("score");
    $score1 = q->param("score1");
    $team = q->param("team");
    $team1 = q->param("team1");

    #an array to associate the team with the score

    %teamscore_array($team,$score,$team1,$score1)
    $teamscore = @teamscore_array{$score}
    $teamscore1 = @teamscore_array{$score1}


    #one array for all the teams associated with the divisions
    %division('globe troters', divA,'the magic',divA,'lakers',divB,'bears',divC)#etc

    #this gets the teams division

    $teamdivision = @division{$team}
    $teamdivisoin1 = @division($team1}

    #this checks if they are in the same division and adds +1 to the winning team in the data base

    if ($teamdivision eq $teamdivision1)
    {if ($teamscore > $teamscore1)
    {#add 1 to $team in division $teamdivision in your database}
    else {#add 1 to $team1 $teamdivision in your database}
    }

    or if you want to stick with arrays, make an associative array with the team names and their current scores

    %teamsandscores_array('the magic',10,'jazz',20)#etc

    #this gets the winning team
    if ($teamscore > $teamscore1)
    {$winningteam = $team}
    else{$winningteam = $team1}

    #this updates the winning teams score

    $teamsandscores_array{$winningteam}(+1)

    I havent used the array method before but in theory it should work

    use the logic for the rest

    Good luck


    [This message has been edited by chrisdice4 (edited October 27, 2000).]

    [This message has been edited by chrisdice4 (edited October 27, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Thanks for the tip! I was able to determine conference, division, home, away, overtime, and overall wins and losses. Thanks again!

    Mike

IMN logo majestic logo threadwatch logo seochat tools logo