Отправка друзьям 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
// Отправка друзьям
$friends = mysql_query("SELECT * FROM `friends_all` WHERE `user` = '".$user['id']."' AND `i` = '1'");
while ($f = mysql_fetch_array($friends))
{
$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))
{
$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() ."')");
}