PHP counting problem

05/25/2014 18:20 mlukac89#1
Hi
I have this piece of code and i need to get teams by rank based on team points, but it wont work as i planned to

Here is image

[Only registered and activated users can see links. Click Here To Register...]

Code:
<table width="100%" class="ladder-table2">
	<tr>
		<th style="width:7%;">#</th>
		<th style="width:70%;">Team</th>
		<th style="width:6%;">W</th>
		<th style="width:6%;">D</th>
		<th style="width:6%;">L</th>
		<th style="width:12%;">Points</th>
	</tr>
	<?php

		$position = 1;
		foreach ($get_team_id as $gti)
		{
			$tid = $gti['team_id']; // team id

			// get teams points
			$get_team_points = $teams->ladders_get_team_points($id, $tid);

			// get team name
			$get_team_name = $teams->ladders_get_team_name($tid);
			foreach ($get_team_points as $gtp)
			{
				foreach ($get_team_name as $gtn)
				{
					echo '<tr>';
					echo '
						<td>'.$position.'</td>
						<td><a href="index.php?page=teams&teamID='.$gtn['id'].'" title="'.$gtn['team_name'].'">'.$gtn['team_name'].'</td>
						<td>'.$gtp['team_wins'].'</td>
						<td>'.$gtp['team_draws'].'</td>
						<td>'.$gtp['team_loses'].'</td>
						<td>'.$gtp['team_points'].'</td>
						';
					echo '</tr>';
				}
			}
		$position++;
		}
	?>
</table>
05/25/2014 18:45 Synatex#2
There is a cool function called sort ( [Only registered and activated users can see links. Click Here To Register...] ) which should help you.