Отправка друзьям friends mysql_query SELECT FROM friends_all WHERE use

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Отправка друзьям
$friends = mysql_query("SELECT * FROM `friends_all` WHERE `user` = '".$user['id']."' AND `i` = '1'");
while ($f = mysql_fetch_array($friends))
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `reader_all` WHERE `user` = '".$user['id']."' AND `reader` = '".$f['reader']."' LIMIT 1"), 0) == 1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `friends_all` WHERE `user` = '".$user['id']."' AND `i` = '1' AND `frend` = '".$f['frend']."' LIMIT 1"), 0) == 1) {
$a = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$f['frend']."' LIMIT 1"));
$msg_lenta = "Создал запись $user[login] <a href=/pages/diaries/?menu=view&id=".$insert.">".$name."</a>";
mysql_query("INSERT INTO `notifications` (`user_id`, `from_id`, `msg`, `time`) values('". $a['id'] ."', '". $a['id'] ."', '".$msg_lenta."', '". time() ."')");
}
}
// Отправка подписчикам
$friends = mysql_query("SELECT * FROM `reader_all` WHERE `user` = '".$user['id']."'");
while ($f = mysql_fetch_array($friends))
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `friends_all` WHERE `user` = '".$user['id']."' AND `i` = '1' AND `frend` = '".$f['frend']."' LIMIT 1"), 0) == 0) {
$a = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$f['reader']."' LIMIT 1"));
$msg_lenta = "Создал запись $user[login] <a href=/pages/diaries/?menu=view&id=".$insert.">".$name."</a>";
mysql_query("INSERT INTO `notifications` (`user_id`, `from_id`, `msg`, `time`) values('". $a['id'] ."', '". $a['id'] ."', '".$msg_lenta."', '". time() ."')");
}
}