Файл: WM-Koder/search.php
Строк: 27
<?php
require 'system/sid.php';
require 'system/config.php';
include 'system/user.php';
include 'system/head.php';
include 'system/navigator.php';
whorm(0, 'search');
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do) {
default:
if (isset($_SESSION['sS'])) unset($_SESSION['sS']);
if (isset($_SESSION['wW'])) unset($_SESSION['wW']);
echo $div_title . 'Поиск пользователя' . $div_end;
echo '<form method="post" action="?do=result">
<input type="search" name="s" placeholder="Ник или ID"/>
<br/>
<input type="radio" name="w" checked value="1"/> по нику
<input type="radio" name="w" value="2"/> по id
<br/>
<input type="submit" name="ok" value="Искать"/>
</form>';
break;
case result:
echo $div_title . 'Результаты поиска' . $div_end;
$s = my_check($_POST['s']);
$w = my_int($_POST['w']);
if (!isset($_SESSION['sS'])) $_SESSION['sS'] = $s;
if (!isset($_SESSION['wW'])) $_SESSION['wW'] = $w;
$str = ($_SESSION['wW'] == 1) ? "user LIKE '%$_SESSION[sS]%'" : "id = '$_SESSION[sS]'";
echo 'Вы искали: <b>' . $_SESSION['sS'] . '</b> ' . ($_SESSION['wW'] == 1 ? 'по нику' : 'по id') . '<br/>
<a href="?">Новый поиск</a><br/>';
$Search = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE $str"), 0);
if ($Search != 0)
{
$n = new navigator($Search, 10, '?do=result&');
$res = mysql_query("SELECT id FROM users WHERE $str ORDER BY id DESC {$n->limit}");
while($a = mysql_fetch_assoc($res))
{
echo us($a['id']) . '<br/>';
}
echo $n->navi();
} else {
echo 'Не найдено.<br/>';
}
break;
}
include 'system/foot.php';
?>