<form class="<?php if ($_GET['p']>100){echo "p_block";}elseif ($_GET['p']==3){echo "black_block clr_or";}else{echo "p_block_r";} ?> ssm rgt" id="feditrating" method="post">
<?php
if (empty($_POST["add_rat"])){
$_SESSION['rating_galary_no'] = 0;
?>
Оцените работу: 
1<input class="cinline" type="radio" name="add_rat" value=1 onclick="document.getElementById('feditrating').submit();" />
2<input class="cinline" type="radio" name="add_rat" value=2 onclick="document.getElementById('feditrating').submit();" />
3<input class="cinline" type="radio" name="add_rat" value=3 onclick="document.getElementById('feditrating').submit();" />
4<input class="cinline" type="radio" name="add_rat" value=4 onclick="document.getElementById('feditrating').submit();" />
5<input class="cinline" type="radio" name="add_rat" value=5 onclick="document.getElementById('feditrating').submit();" />
<?php }else{$_SESSION['rating_galary_no']++;} ?>
<span class="sm bld" <?php if ($_GET['p']<8){echo "style='color:#FFF9F0;'";} ?>>&nbsp;Рейтинг: 
<?php 
mysql_select_db('onestyle_w');
$rat_result = mysql_query("select c_word_id, c_rcount, c_rating from ocView_" . $_GET['p'] . " where c_word_id= " . $_GET['u']);
if (isset($_POST["add_rat"])){
	if ($_SESSION['rating_galary_no'] < 2){
		if (mysql_num_rows($rat_result)){
			mysql_query("update ocView_" . $_GET['p'] . " set c_rcount = (c_rcount + 1) where c_word_id= " . $_GET['u']);
			mysql_query("update ocView_" . $_GET['p'] . " set c_rating = (c_rating + " . $_POST["add_rat"] . ") where c_word_id= " . $_GET['u']);
		}else{
			mysql_query("insert into ocView_" . $_GET['p'] . "  values (" . $_GET['u'] . ", 0, " . $_POST["add_rat"] . ", 1)");
		}
	}
}

$rat_result = mysql_query("select c_word_id, c_rcount, c_rating from ocView_" . $_GET['p'] . " where c_word_id= " . $_GET['u']);
if (mysql_num_rows($rat_result)){
	$rat_row = mysql_fetch_array($rat_result);
	if ($rat_row['c_rcount'] == 0){echo "0";}else{echo number_format((float)($rat_row['c_rating']/$rat_row['c_rcount']), 2) . " / " . $rat_row['c_rcount'];}
}else{
	echo "0";
}
mysql_select_db('onestyle_testmy');
?>&nbsp;</span></form>