Файл: play_gamescool/bar/rate.php
Строк: 49
<?php
include_once '../../connect.php';
include_once '../../head.php';
include_once 'inc/start.php';
if(isset($_POST['search'])){
$sort=$_POST['sort1'];
$sort_order=$_POST['sort2'];
if(!in_array($sort,array('level','money','exp','nap')))$sort='level';
if(!in_array($sort_order,array('ASC','DESC')))$sort_order='ASC';
$_SESSION['bar_sort']=mysql_real_escape_string($sort);
$_SESSION['bar_sort_order']=mysql_real_escape_string($sort_order);
}
$sort=(isset($_SESSION['bar_sort']) ? $_SESSION['bar_sort'] : 'level');
$sort_order=(isset($_SESSION['bar_sort_order']) ? $_SESSION['bar_sort_order'] : 'ASC');
echo "
<div class='".$diz['main']."'>
<div class='".$diz['title2']."'>Сортировка</div>
<form method='post' action='rate.php?".mt_rand()."'>
<select name='sort1'>
<option value='level' ".($sort=='level' ? "selected='select'" : "").">По уровню</option>
<option value='money' ".($sort=='money' ? "selected='select'" : "").">По деньгам</option>
<option value='exp' ".($sort=='exp' ? "selected='select'" : "").">По опыту</option>
<option value='nap' ".($sort=='nap' ? "selected='select'" : "").">По кол-ву опьянений</option>
</select>
<select name='sort2'>
<option value='ASC' ".($sort_order=='ASC' ? "selected='select'" : "").">По возрастанию</option>
<option value='DESC' ".($sort_order=='DESC' ? "selected='select'" : "").">По убыванию</option>
</select>
<input type='submit' name='search' value='»'/></form>
<div class='".$diz['title2']."'>Рейтинг</div>
";
$total=mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_user`"),0);
$tmp_array=array('level'=>'Уровень','money'=>'Деньги','exp'=>'Опыт','nap'=>'Напился');
if($total>0){
$quert=mysql_query("SELECT * FROM `bar_user` ORDER BY `".$sort."` ".$sort_order." LIMIT ".$start.",5");
$i=0;
while($array=mysql_fetch_array($quert)){
$post=($i%2 ? $diz['post_1'] : $diz['post_2']);
echo '<div class="'.$post.'">
<table cellpadding="0">
<tr>
<td>
<img src="i/user_male.png"/>
</td>
<td>
<a href="profile.php?id='.$array['id_u'].'">'.$array['login'].'</a><br/>
'.$tmp_array[$sort].' : '.$array[$sort].' '.($sort=='nap' ? "раз" : "").'
<br/>
</td></tr></table></div>';
$i++;
}
if ($total > 5){
echo bar_pagenav('rate.php?', $start, $total, 5);
}
}
echo "</div>";
ret($diz['ret'],'Мой бар','index.php');
include_once '../../foot.php';
?>