Welcome Guest, Not a member yet? Register   Sign In
Ordered list for league standings - what about ties?
#11

[eluser]RayDube[/eluser]
That was it, it was me trying to add the pos to the wrong array...

Now this works.. Smile

Code:
if($query->num_rows()>0)
    {
      foreach ($query->result_array() as $row)
      {
        $this->Points = $row['Points'];
        $this->Wins = $row['Wins'];
        if ($this->PrevPoints == $this->Points)
        {
          if ($this->PrevWins == $this->Wins)
          {
            $row['pos'] = $this->pos;
          }
          else
          {
            $this->pos++;
            $row['pos'] = $this->pos;
          }
        }
        else
        {
          $this->pos++;
          $row['pos'] = $this->pos;
        }
        $this->PrevPoints = $this->Points;
        $this->PrevWins = $this->Wins;
        $data[]=$row;
      }
      $query->free_result();
      return $data;
    }

With the following changes to the view:
Code:
<?php foreach($records as $row) :?>
        <tr>
          <td>&lt;?php echo $row['pos']; ?&gt;</td>
          <td>&lt;?php echo $row['Team_Name']; ?&gt;</td>
          <td>&lt;?php echo $row['Wins']; ?&gt;</td>
          <td>&lt;?php echo $row['Losses']; ?&gt;</td>
          <td>&lt;?php echo $row['Ties']; ?&gt;</td>
          <td>&lt;?php echo $row['Points']; ?&gt;</td>

Thanks very much for your help Ben, it is appreciated, even if I was blind at times... Smile

Ray




Theme © iAndrew 2016 - Forum software by © MyBB