Detect future duplicate values while iterating through MySQL results in PHP

后端 未结 3 837
我在风中等你
我在风中等你 2020-12-21 11:03

I am trying to calculate a ranking of a team in an ordered MySQL result set, and the issue I\'m having is detecting ties for the first team to show up with the tied

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-21 11:31

    $exists = array();
    if ($row['team_id'] == $team_id && !in_array($row['pts'], $exists)) { //current team in resultset matches team in question, set team's rank
            $exists[] = $row['pts'];
            $arr_ranks['tp']['cat'] = 'Total Points';
            $arr_ranks['tp']['actual'] = number_format($row['pts'],1);
            $arr_ranks['tp']['league_rank'] = $rnk;
            $arr_ranks['tp']['div_rank'] = $div_rnk;
        }
    

提交回复
热议问题