Hello i want to make notification when new message is received, i have a row seen
with values 0
and 1
if is 0 then its unread else is seen i got this code but when it displays the output shows the number of rows but for example i have 3 uread messages it displays 111
and not just 3
i tried with strlen to get the value but i cant please any help ?
function check_messages() {
global $conn;
$user = getUserData('users', 'UserUsername');
$sql = "SELECT seen FROM ticket WHERE receiverName='{$user}'";
$result = $conn->query($sql);
$count = 0;
if(!$result){
echo "Problem!";
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else {
if($result->num_rows > 0) {
$count++;
$num_length = strlen((int)$count);
while($row = $result->fetch_assoc()){
$seen = $row["seen"];
if($seen == '0'){
echo $num_length;
}
}
}
}
$conn->close();
}