<div id="div_12">
<table style="width:100%;"><tr><td class="sm rgt" style="width:20%;padding:0px 3px;">
<p class="bld">Комментарии</p>
<?php 	mysql_select_db('onestyle_w'); ?>
<p>Проекты <span class="bld">[</span> <?php echo mysql_num_rows(mysql_query("select commentid from octblTag_3")); ?> <span class="bld">]</span><br />
Галерея <span class="bld">[</span> <?php echo mysql_num_rows(mysql_query("select commentid from octblTag_8")); ?> <span class="bld">]</span></p>
<?php
for($j= 1;$j<=6;$j++){
	echo "<p>";
	for($i=1;$i<=count($obase);$i++){
		if ($obase[$i][2] == $j){
			echo $obase[$i][0] . ' <span class="bld">[</span> ' . mysql_num_rows(mysql_query("select commentid from octblTag_" . (2*$i + 100))) . ' <span class="bld">]</span><br />';
		}
	}
	echo "</p>";
}
?>

</td><td><FORM class="black_block" METHOD="POST" id="fchangedirect">
<select class="cinline" name="direct_job" onchange="javascript:document.getElementById('fchangedirect').submit();">
<option>Выберите раздел</option>
<option value=3 <?php if (($_GET['d'] == 3)or($_POST['direct_job']== 3)) {echo "selected";} ?>>Проекты</option>
<option value=8 <?php if (($_GET['d'] == 8)or($_POST['direct_job']== 8)) {echo "selected";} ?>>Галерея</option>
<?php
for($i=1;$i<=count($obase);$i++){
	echo "<option value=" . (2*$i + 100) . " ";
	if (($_GET['d'] == (2*$i + 100))or($_POST['direct_job']== (2*$i + 100))) {echo "selected";}
	echo ">" . $obase[$i][0] . "</option>";
}
?>

</select>
</FORM>
<?php
if ((isset($_POST['direct_job']) and ($_POST['direct_job'] <> "Выберите раздел")) or (isset($_GET['d']))){
	$tmp1 = "obd_";
	if (isset($_POST['direct_job'])) {$_POST['direct_job'] = intval($_POST['direct_job']);}else{$_POST['direct_job'] = intval($_GET['d']);};
	if ($_POST['direct_job'] > 100){$tmp1 .= ($_POST['direct_job'] - 1);}elseif($_POST['direct_job'] == 3){$tmp1 .= "0";}else{$tmp1 .= $_POST['direct_job'];}

	$query = "select distinct c_word_id, onestyle_testmy." . $tmp1 . ".jobid";
	if ($_POST['direct_job'] <> 8){$query .= ", onestyle_testmy." . $tmp1 . ".name as name";}
	$query .= " from octblTag_" . $_POST['direct_job'] . ", onestyle_testmy." . $tmp1 . " where c_word_id = onestyle_testmy." . $tmp1 . ".jobid";

	//проверка лимита
	$result = mysql_query($query);
	$z = mysql_num_rows($result);
	if (isset($_GET['l'])){$query .= " limit " .$_GET['l'] . "," . $cur_list_numb;}else{$query = $query . " limit 0," . $cur_list_numb;}
	$result = mysql_query($query);
	$num_result = mysql_num_rows($result);

?>
<div class="black_block_c">
<?php
	if ($num_result){
	for ($i=0; $i<$num_result; $i++){
		$row = mysql_fetch_array($result);
?>

<div class="p_block"><?php
echo "<span style='font-weight : bold;'>[&nbsp;";
if (isset($_GET['l'])){
	echo $i + 1 + $_GET['l'];}
else{
	echo $i + 1;
}
echo  "&nbsp;]</span> ";
if ($_POST['direct_job'] <> 8){
?>
<a class="a_show_hide" title="Открыть страницу записи" target="_blank" href="<?php if ($_POST['direct_job'] < 100){echo $site_pages[$_POST['direct_job']][1] . "?";} else {echo "/online.php?p=" . $_POST['direct_job'] . "&";} ?>u=<?php echo $row['c_word_id']; ?>"><?php
echo stripslashes($row['name']); ?></a>
<?php } ?>
</div>
<table style="width:100%"><tr>
<?php 
if ($_POST['direct_job'] == 8){
	if ($row['c_word_id'] >= 2000){
		$glavagal = 'other/';
		$curpgal = $row['c_word_id'] - 2000;
	}elseif ($row['c_word_id'] >= 1000){
		$glavagal = 'fon/';
		$curpgal = $row['c_word_id'] - 1000;
	}else {
		$glavagal = 'interier/';
		$curpgal = $row['c_word_id'];
	}
?>
<td class="cntr" style="width:110px">
<a target="_blank" href="galary.php?u=<?php echo $row['c_word_id']; ?>"><img id="gal3" src="galary/litle/<?php echo $glavagal . $curpgal . ".jpg"; ?>" /></a>
</td>
<?php
}
?>
<td>
<p class="sm" style="padding:0px 5px 5px;"><span class="bld">Комментариев&nbsp;[&nbsp;</span><a title="Открыть страницу записи" target="_blank" href="<?php if ($_POST['direct_job'] < 100){echo $site_pages[$_POST['direct_job']][1] . "?";} else {echo "/online.php?p=" . $_POST['direct_job'] . "&";} ?>u=<?php echo $row['c_word_id']; ?>#add_comment"><?php
	echo mysql_num_rows(mysql_query("select c_word_id from octblTag_" . $_POST['direct_job'] . " where c_word_id = " . $row['c_word_id']));
?></a>
<?php
	echo "<span class='bld'>&nbsp;]&nbsp;&nbsp;</span>Просмотров<span class='bld'>&nbsp;[&nbsp;</span>";
	$result2 = mysql_query("select * from ocView_" . $_POST['direct_job'] . " where c_word_id= " . $row['c_word_id']);
	if (mysql_num_rows($result2)){
		$row2 = mysql_fetch_array($result2);
		echo $row2['c_count'];
	}else{
		echo "0";
	}

echo "<span class='bld'>&nbsp;]&nbsp;&nbsp;</span>Рейтинг<span class='bld'>&nbsp;[&nbsp;</span>";

$result2 = mysql_query("select c_word_id, c_rcount, c_rating from ocView_" . $_POST['direct_job'] . " where c_word_id= " . $row['c_word_id']);

if (mysql_num_rows($result2)){
	$row2 = mysql_fetch_array($result2);
	if ($row2['c_rcount'] == 0){echo "0";}else{echo number_format((float)($row2['c_rating']/$row2['c_rcount']), 2);}
}else{
	echo "0";
}
echo "<span class='bld'>&nbsp;]</span>";
//mysql_select_db('onestyle_testmy');
?>
</p>
</td></tr></table>		
		
<?php		
	}
	}else{
		none_project();
	}
?>
</div>
<?php
require "../find_project_res.php";
	mysql_select_db('onestyle_testmy');
}
?>
</td></tr></table>
</div>