<?php
require_once $_SERVER['DOCUMENT_ROOT']."/includes/start.php";
if(isset($_SESSION['auth']) and $_SESSION['auth']==1){
echo $_up;

echo '<b>Подарки:</b><br>';

$count_pres=mysql_result(mysql_query("SELECT COUNT(*) FROM `presents` WHERE `id_user`='$usr[id]'"), 0);
$page=isset($_GET['p'])?$_GET['p']:1;

$pres_q=mysql_query("SELECT * FROM `presents` WHERE `id_user`='$usr[id]' ORDER BY `id` LIMIT ".(($page-1)*10).", 10");

if($count_pres==0){
echo 'Подарков нет :(';
}

while($post=mysql_fetch_array($pres_q)){

$present = mysql_fetch_assoc(mysql_query("SELECT `id_present`,`name`,`img`,`price` FROM `shop` WHERE `id_present`='$post[id_present]'")); //запрос на логин юзера
$from_id = mysql_fetch_assoc(mysql_query("SELECT `login` FROM `users` WHERE `id`='$post[from_id]'")); //запрос на логин юзера


echo'<table width="70%"><tr><td valign="top" width="20%" style="font-size: 12px;font-family: Verdana, Arial;">';


echo '<img src="'.$present['img'].'" align="left" style="margin:1px 5px 1px 0px;" width="50" height="50"/>';


echo '</td><td valign="top" style="font-size: 11px;font-family: Verdana, Arial;">
<b><u>'.$present['name'].'</u></b><br>
<b>Когда:</b> '.$post['date'].'<br>
<b>Комментарий:</b> '.$post['from_text'].'<br>
<b>От:</b> '.$from_id['login'].'<br>
<a href="present_del.php?id='.$post['id'].'"><b style="color:#ff0000;">Удалить</b></a>';
echo '</td></tr></table>';
}
nav($count_pres, $page, '?', 10); //навигация




echo '</div>'; echo $_down;

}else{

header ("Location: ?"); exit;

}

?>