/
home
/
techb158
/
workloadmatch.com
/
api
/
chat
/
/home/techb158/workloadmatch.com/api/chat
mkdir
upload
Name
Size
Mode
Actions
fetch.php
2034
0644
edit
dl
rm
send.php
1319
0644
edit
dl
rm
test.php
908
0644
edit
dl
rm
unread_count.php
745
0644
edit
dl
rm
Edit:
/home/techb158/workloadmatch.com/api/chat/unread_count.php
(745B)
<?php include_once '../../includes/db_connect.php'; include_once '../../includes/functions.php'; sec_session_start(); header('Content-Type: application/json'); $userId = isset($_SESSION['user_id']) ? (int)$_SESSION['user_id'] : 0; if (!$userId) { echo json_encode(['count' => 0]); exit; } $user_type = $_GET['user_type'] ?? 'manager'; $stmt = $mysqli->prepare("SELECT COUNT(*) AS cnt FROM chat_messages WHERE receiver_id = ? AND receiver_type = ? AND is_read = 0"); if (!$stmt) { echo json_encode(['count' => 0]); exit; } $stmt->bind_param("is", $userId, $user_type); $stmt->execute(); $res = $stmt->get_result(); $row = $res->fetch_assoc(); echo json_encode(['count' => (int)$row['cnt']]); $stmt->close(); $mysqli->close();
Save
cmd:
run