-
Notifications
You must be signed in to change notification settings - Fork 1
/
message_count.php
84 lines (37 loc) · 1001 Bytes
/
message_count.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Created by PhpStorm.
* User: BlackLion
* Date: 7/9/2018
* Time: 8:41 AM
*/
require 'db.php';
if(isset($_GET['user_id']))
{
$user_id = $_GET['user_id'];
$result=$mysqli->query("SELECT COUNT(id) as counts FROM notifications WHERE target_user_ids = '$user_id' and delete_receiver='0' and is_seen='0'");
if($result->num_rows >0)
{
$data = $result->fetch_assoc();
echo $data['counts'];
}else
{
echo '0';
}
}else
{
if(isset($_POST['msg_id']))
{
$msg_id = $_POST['msg_id'];
if($mysqli->query("UPDATE notifications SET is_seen='1' WHERE id='$msg_id'"))
{
echo $msg_id;
}else
{
echo '0';
}
}else
{
echo '0';
}
}