Просмотр файла includes/comm_by.php

Размер файла: 1.6Kb
<?php

$user_r = mysql_query("select `id` from `users` where `id` = '$id'");
$user = mysql_fetch_assoc($user_r);
if ($user['id']) {
	switch ($type) {
		case 'blogs': $index = 'Блоги'; break;
		case 'loads': $index = 'ЗЦ'; break;
		case 'photos': $index = 'Фото'; break;
	}
	echo '<div class="title"><a href="index.php">'.$index.'</a>&raquo; комментарии '.username($id, 1).'</div>';
	$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `".$type."_comm` WHERE `id_user` = '$id'"), 0);
	if ($total > 0) {
		$pages = ceil($total / $config['onpage']);
		if ($page > $pages or $page == 0) {
			$page = 1;
		}
		$begin = ($page - 1) * $config['onpage'];

		$comm_r = mysql_query("SELECT * FROM `".$type."_comm` WHERE `id_user` = '$id' ORDER BY `time` DESC LIMIT $begin, $config[onpage]");
		while ($comm = mysql_fetch_assoc($comm_r)) {
			$typen = mysql_fetch_assoc(mysql_query("select `name` from $type where `id` = '".$comm['id_'.$type]."'"));
			$comms = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `".$type."_comm` WHERE `id_$type` = '".$comm['id_'.$type]."'"), 0);
			echo '<div class="row"><a href="index.php?act=comm&amp;id='.$comm['id_'.$type].'"><b>'.$typen['name'].'</b> ('.$comms.')<br />'.$comm['text'].'<br />Написано: '.ccdate($comm['time'], 0).'</a></div>';
		}
	} else {
		echo '<div class="body">Их пока нет</div>';
	}
	echo '<div class="body">';
	navig($page, '?act=comm_by&amp;id='.$id.'&amp;', $pages);
	echo '<a href="index.php">'.$index.'</a>&raquo; комментарии '.username($id, 2).'</div>';
} else {
	redirect('?');
}

?>