<?php
include '../config.php';
include '../func.php';
head();
aut();
ban();

####################Запись онлайна##################
mysql_query("UPDATE `profile` SET `online` = 'service' WHERE `id` = '".$id_session."'");
####################################################
echo head ."Сервисы / <b>Значение имени</b>".div.katalog;

$link1 = '<a href ="?">Имена</a><br />';
if(!isset($_GET['search'])) {
if(empty($_GET['sex']) && empty($_GET['name'])) {
$link = '/';
$q = mysql_query("SELECT * FROM `names_cat` WHERE `sex` = 'a' OR `sex` = 'm';");
echo '<b>Мужские имена:</b><br/>';
	while($list = mysql_fetch_array($q)) {
	echo ' <a href = "?sex=m&amp;name='.$list['b'].'">'.$list['n'].'</a> ';
	}
echo '<br/><br/>';
$q = mysql_query("SELECT * FROM `names_cat` WHERE `sex` = 'a' OR `sex` = 'w';");
echo '<b>Женские имена:</b><br/>';
	while($list = mysql_fetch_array($q)) {
	echo ' <a href = "?sex=w&amp;name='.$list['b'].'">'.$list['n'].'</a> ';
	}

echo '<br/><br/><form action="live.php" method="get">
<p><input type="text" value="" name="search" />
<input type="submit" value="Поиск" name="submit" />
</p></form>';
} else {
	if(isset($_GET['id'])) {
	$link = '?sex='.$_GET['sex'].'&amp;name='.$_GET['name'];
	$q = mysql_query("SELECT * FROM `names` WHERE `id` = '".intval($_GET['id'])."';");
		if(mysql_num_rows($q)) {
		$list = mysql_fetch_array($q);
		echo '<div class="list2"><b>'.$list['name'].'</b></div>'
			.'<div class="list1">'.$list['opis'].'</div>';
		} else {
		echo 'Ошибка! Такого имени нет<br />';
		}
	} else {
	$link = '?';
	echo '<div class="menu">';
	$q = mysql_query("SELECT * FROM `names` WHERE `sex` = '".mysql_real_escape_string($_GET['sex'])."' AND `idname` = '".mysql_real_escape_string($_GET['name'])."' ;");
		if(mysql_num_rows($q)) {
			while($list = mysql_fetch_array($q)) {
			echo '<a href = "?sex='.$_GET['sex'].'&amp;name='.$_GET['name'].'&amp;id='.$list['id'].'">'.$list['name'].'</a><br />';
			}
		} else {
		echo 'В разделе нет имён';
		}
	echo '</div>';
	}
}
} else {
if(isset($_GET['user'])) {
$link = '../users/profile.php?act=info&amp;user='.intval($_GET['user']);
} else {
$link = '?';
}
$q = mysql_query("SELECT * FROM `names` WHERE `name` = '".mysql_real_escape_string($_GET['search'])."';");
	if(mysql_num_rows($q)) {
	$list = mysql_fetch_array($q);
	echo '<div class="news"><b>'.$list['name'].'</b></div>'
		.'<div class="news">'.$list['opis'].'</div>';
	} else {
	echo 'Данного имени нет в базе<br />';
	}
}


echo div;
navig();
foot();
?>