Просмотр файла msgshow.php

Размер файла: 1.87Kb
<?
session_start(); //инициализирум механизм сесссий
include 'include/stat.php';
if (!isset($_SESSION['id']))
{
header ("location: logout.php");
exit('incorrect');
}
include 'include/sys.php';
include 'include/game.php';
?>

<?include 'include/head.php';?>

<div class="in">Сообщения</div>
<?include'include/menu.php';?>
<?

if ($_GET['box']=='in'){ //ВХОДЯЩИЕ
$p=def($_GET['p']);
if (empty($p)){$p=1;}
$off = ($p-1)*10;

function pages ($p)
{
$res = count_query("select count(*) from mail WHERE to_id= '".$_SESSION['id']."'");
$row = mysql_result($res,0);
$b = ceil(($row/10))  ;
$x=1;
while ($b>=$x)
{
if ($x==$p){$pages .= ' ['.$x.'] ';} else{$pages .= ' <a href="?box=in&p='.$x.'">'.$x.'</a> ';  }
$x++;
}

return $pages;
}

$res = count_query("SELECT *
FROM mail
WHERE to_id= '".$_SESSION['id']."'
ORDER BY id DESC LIMIT $off,10 ");
$cont1 = mysql_fetch_assoc($res);

while ($cont1)
{
print"	<div class='link'>";
echo $cont1['from_id'];
echo"(".$cont1['subj'].")</div>".$cont1['msg']."+";
$cont1 = mysql_fetch_assoc($res);
}
echo '</br>';
echo pages ($p);
}

if ($_GET['box']=='out'){ //UCXOD
$p=def($_GET['p']);
if (empty($p)){$p=1;}

function pages ($p){
$res = count_query("select count(*) from mail WHERE from_id= '".$_SESSION['id']."'");
$row = mysql_result($res,0);

$b = ceil(($row/10))  ;

$x=1;
while ($b>=$x)
{
if ($x==$p){$pages .= ' ['.$x.'] ';} else{$pages .= ' <a href="?box=in&p='.$x.'">'.$x.'</a> ';  }

$x++;
}

return $pages;
}
$off = ($p-1)*10;

$res = count_query("select * from mail WHERE from_id= '".$_SESSION['id']."' limit $off,10");
$cont1 = mysql_fetch_assoc($res);

while ($cont1){
print"	<div class='link'>".$cont1['to_id']."(".$cont1['subj'].")</div>".$cont1['msg']." +";
$cont1 = mysql_fetch_assoc($res);
}
echo '</br>';
echo pages ($p);
}

?>


</div>
<?include 'include/foot.php';?>