http://www.icyphoenix.com/viewtopic.php?f=26&t=6899&p=47424#p47424
-----------------------------------
KugeLSichA
Sat 30 Jan, 2010 15:51

SQL And Code Help Needed
-----------------------------------
Hi Friends,

I hope someone can help me to solve this...

I have this code:

[spoiler]
[code linenumbers=false]
<?php

$template->_tpldata['signup_players.'] = array();
$template->_tpldata['no_players'] = array();

// users-query
$sql = "SELECT u.* FROM " . TOURNEY_SEASON_USERS_TABLE . " su, " . USERS_TABLE . " u
		WHERE su.id_season = " . $_REQUEST['season_id'] . "
			AND su.usertype_player = 1
			AND su.rejected = 0
			AND su.id_user = u.user_id
				ORDER BY su.submitted ASC";
if (!($result = $db->sql_query($sql)))
{
	message_die(GENERAL_ERROR, 'Could not connect to tourney users and season users table.', '', __LINE__, __FILE__, $sql);
}

$signuprow = array();

while ($row = $db->sql_fetchrow($result))
{
	$signuprow[] = $row;
}
$db->sql_freeresult($result);

$total_players = count($signuprow);

$cols_number = 4;
$rows_number = $total_players / $cols_number;

if ($total_players > 0)
{
  $player_counter = 0;
	while( $player_counter < $total_players )
	{
		for ($x = 0; $x < $rows_number; $x++)
		{
			$template->assign_block_vars('signup_players', array());

			for ($y = 0; $y < $cols_number; $y++)
			{
				if ( $player_counter >= $total_players )
				{
					$template->assign_block_vars('signup_players.no_detail', array());
				}
				else
				{
					$sql = "SELECT f.flag_image, f.flag_name, u.user_from_flag
							FROM " . FLAG_TABLE . " AS f
								LEFT JOIN " . USERS_TABLE . " AS u ON f.flag_image = u.user_from_flag
							WHERE f.flag_image = '" . $signuprow[$player_counter]['user_from_flag'] . "'";
					if(!$result = $db->sql_query($sql))
					{
						message_die(GENERAL_ERROR, 'Could not obtain last edit information from the database', '', __LINE__, __FILE__, $sql);
					}
					$flagrow = $db->sql_fetchrow($result);

					$player = colorize_username($signuprow[$player_counter]['user_id']);
					$template->assign_block_vars('signup_players.detail', array(
						'PLAYER' => $player,
						'PLAYER_COUNTER' => $player_counter + 1,
						'FLAG_IMAGE' => $signuprow[$player_counter]['user_from_flag'],
						//'FLAG_NAME' => $flagrow['flag_name']
						)
					);
				}
				$player_counter++;
			}
		}
	}
}
else
{
	$template->assign_block_vars('no_players', array());
}

$template->assign_vars(array(
	'S_COL_WIDTH' => (100 / ( ($cols_number == 0) ? 4 : $cols_number )) . '%',
	)
);

?>
[/code]

[code linenumbers=false]
<!-- INCLUDE tourney_main_body.tpl -->

<table class="forumlinenb" width="100%" cellspacing="0" cellpadding="0" align="center">
<tr><th colspan="{S_COL_WIDTH}">{L_T_PLAYERS_OVERVIEW}</th></tr>
<!-- BEGIN no_players -->
<tr><td class="row1 row-center" colspan="{S_COL_WIDTH}">{L_T_NO_PLAYERS}</td></tr>
<!-- END no_players -->
<!-- BEGIN signup_players -->
<tr>
	<!-- BEGIN detail -->
	<td class="row1 row-center" width="{S_COL_WIDTH}">
		<table>
		<tr>
			<td><span class="genmed">{signup_players.detail.PLAYER_COUNTER}</span></td>
			<td><span class="genmed"><img src="images/flags/{signup_players.detail.FLAG_IMAGE}" /></span></td>
			<td><span class="genmed">{signup_players.detail.PLAYER}</span></td>
		</tr>
		</table>
	</td>
	<!-- END detail -->
	<!-- BEGIN no_detail -->
	<td class="row1 row-center"><span class="genmed">&nbsp;</span></td>
	<!-- END no_detail -->
</tr>
<!-- END signup_players -->
</table>{IMG_TFL}{IMG_TFC}{IMG_TFR}
<br />
<table class="forumlinenb" width="100%" cellspacing="0" cellpadding="0" align="center">
<tr><th colspan="{S_COL_WIDTH}">Countries Overview</th></tr>

<tr><td class="row1 row-center" colspan="{S_COL_WIDTH}">no countries</td></tr>

</table>{IMG_TFL}{IMG_TFC}{IMG_TFR}

<!-- close nav table -->
	</td>
</tr>
</table>{IMG_TFL}{IMG_TFC}{IMG_TFR}
[/code]

[/spoiler]

which results in this:

 [img]http://www.icyphoenix.com/files/images/6/tourney1.jpg[/img] 

but i also want to count the countries and layers like here for example:

 [img]http://www.icyphoenix.com/files/images/6/tourney2.jpg[/img] 

Did someone of you know how to, and can help me with this???

thanks  8)


