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

Размер файла: 1.2Kb
<?php
include 'inc/db.php';
include 'inc/1.php';
if (!$user && !isset($_GET['id']))
{
header('Location: /aut.php');
exit();
}
if (!isset($_GET['id']))$_GET['id']=$user['id'];
$q=mysql_query("SELECT `id` FROM `user` WHERE `id` = '".intval($_GET['id'])."'");
if (mysql_num_rows($q)==0)
{
header('Location: /index.php');
exit();
}
$ank=mysql_fetch_assoc(mysql_query("SELECT `id`, `name` FROM `user` WHERE `id` = '".intval($_GET['id'])."'"));
echo '<div class="foot">'.im($ank['id']).' '.$ank['name'].' - Друзья</div>';
$q=mysql_query("SELECT * FROM `friends` WHERE (`user1` = '".intval($_GET['id'])."' OR `user2` = '".intval($_GET['id'])."') AND `ok` = '1'");
if (mysql_num_rows($q)==0)
{
echo '<div class="msg">Друзей пока нет.</div>';
include 'inc/foot.php';
exit();
}
while ($f=mysql_fetch_assoc($q))
{
if ($f['user2']==$user['id'])$aid=$f['user1'];
else
$aid=$f['user2'];
$ank=mysql_fetch_assoc(mysql_query("SELECT `id`, `name` FROM `user` WHERE `id` = '$aid'"));
echo "<div class='p0'>
".im($aid)." <a href='/ank.php?id=$ank[id]'>$ank[name]</a> (".vremja($f['timeok']).")
<br />
[<a href='/frd.php?id=$f[id]'>удалить</a>]
</div>";
}
include 'inc/foot.php';
?>