View file kont.php

File size: 905B
<?php
include 'inc/db.php';
include 'inc/1.php';
if (!$user)header("Location: /aut.php");
$q=mysql_query("SELECT `to`, `from` FROM `mail` WHERE `to` = '$user[id]' OR `from` = '$user[id]' ORDER BY `id` DESC");
$a=array();
while ($f=mysql_fetch_assoc($q)){
if ($f['to']==$user['id']){
$a[]=$f['from'];
}
elseif ($f['from']==$user['id'])
{
$a[]=$f['to'];
}
}
$v=array_unique($a);
$c=count($v);
sort($v);
$b=0;
$o=1;
while ($b<$c){
$ank=gus($v[$b]);
$count=mysql_num_rows(mysql_query("SELECT `id` FROM `mail` WHERE (`to` = '$user[id]' AND `from` = '$v[$b]') OR (`from` = '$user[id]' AND `to` = '$v[$b]')"));
echo "<div class='p".($o%2)."'>".im($ank['id'])." <a href='mail.php?id=$v[$b]'>".htmlspecialchars($ank['name'])."</a> ($count)</div>";
$b++;
$o++;
}
if (mysql_num_rows($q)==0)echo "<div class='msg'>Контактов нет</div>";
include_once 'inc/foot.php';
?>