<h1>Профиль</h1>
<?php
db_connect();
$res = db_query("SELECT * FROM `".DBpref."users` WHERE `login` = '".db_string($_GET["login"])."'");
$row = db_assoc($res);
$rotikdvoiny = db_query("SELECT `id` FROM `".DBpref."users` WHERE `rating` > ".round($row["rating"],4));
db_close();

	$err = NULL;
	if(db_rows($res) == 0)
		$err .= "<li>Пользователь не найден</li>";
	if($err == NULL){
		?>
			
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="120px" align="center">
		<img src="<?php echo $row["img"] == NULL?"/upload/avatars/no.png":htmlspecialchars($row["img"]); ?>" height="100" width="100" alt="" />
		<?php
			echo isset($_SESSION["login"])?'<form method="post" action="/?p=mesages&t=new">
			<input name="recipient" type="hidden" value="'.htmlspecialchars($row["login"]).'" />
			<input type="submit" value="Сообщение" />
		</form>':'';
		?>
	</td>
    <td>
			
<table class="table2">
  <tr>
    <td>Логин: </td>
    <td><?php echo htmlspecialchars($row["login"]); ?></td>
  </tr>
  <tr>
    <td>Рейтинг:</td>
    <td><?php echo round($row["rating"], 4); ?></td>
  </tr>
  <tr>
    <td>Место по рейтингу:</td>
    <td><?php echo db_rows($rotikdvoiny)+1; ?></td>
  </tr>
  <tr>
    <td>Побед:</td>
    <td><?php echo $row["game_win"]; ?></td>
  </tr>
  <tr>
    <td>Поражений:</td>
    <td><?php echo $row["game_loss"]; ?></td>
  </tr>
  <tr>
    <td>Ничьих:</td>
    <td> <?php echo $row["game_draw"]; ?></td>
  </tr>  
  <tr>
    <td>Всего сыграно игр:</td>
    <td> <?php echo $row["game_draw"]+$row["game_loss"]+$row["game_win"]; ?></td>
  </tr>
  <tr>
    <td>Последняя активность:</td>
    <td><?php echo $row["logdat"]; ?></td>
  </tr>
  <tr>
    <td>Дата регистрации:</td>
    <td><?php echo htmlspecialchars($row["regdat"]); ?></td>
  </tr>
</table>
	</td>
  </tr>
</table>
		<?php
	}else{
		echo "<ul>".$err."</ul>";
	}
?>