<?


include 'connect.php';

include 'head.php';
//Подзаголовок
echo '<div class="title"><img src= "img/photos.gif"> <b>ТОП фото</b></div>';

echo '<div class="main_menu">';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `photos_photo` WHERE `top` = '1'"), 0);
if($all > 0){
$total = intval(($all - 1) / 10) + 1;
   $page = intval($_GET['page']);
   if(empty($page) or $page < 0) $page = 1; 
   if($page > $total) $page = $total;
   $start = $page * 10 - 10;
   $result = mysql_query("SELECT * FROM `photos_photo` WHERE `top` = '1' ORDER BY `rating` DESC LIMIT $start, 10");
   while($photo = mysql_fetch_assoc($result)){
   $user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$photo["user"]."'"));
   $arhiv =  intval(($user['id']/1000)+1);
	  //Вывод
	  echo '<div class="block_list">';
      $name = checkout($photo['name']);
      echo '<table>
      <tr>
      <td VALIGN=top>';
	  echo '<a href = "photos.php?act=photo&id='.$photo['id'].'"><img src = "base/'.$arhiv.'/'.$user['id'].'/photos_small/'.$photo['id'].'.jpg" height = "50" ></a>';
	  echo '</td>
	  <td VALIGN=top>';
	  echo ''.ico($user['sex'],$user['admin']).' <a href = "page.php?id='.$user['id'].'">'.$user['login'].'</a> '.online($user['online']).' <br/>';
	  echo '<img src = "img/photos.gif"> <a href = "photos.php?act=photo&id='.$photo['id'].'">Просмотр</a><br/>';
	  echo '<img src = "img/like.png"> <font color = "green">'.$photo['rating'].'</font>';
	  echo '</td>
      </tr>
      </table>';
      echo '</div>';
   } 
   navigation($page, $total,'photos_top.php?');
}else{
echo '<div class = "center">Фотографий пока нет!</div>';
}
echo '</div>';
include 'foot.php';

?>

