I created folowing view (select list of last active users):
SELECT U.login, U.name, U.surname
FROM sessions S LEFT JOIN user U 
ON S.id_user = U.id_user 
WHERE U.id_user != 0 AND UNIX_TIMESTAMP()-S.set_time < 300
ORDER BY S.set_time DESC
SELECT *FROM vonline; gives me(i call it in phpmyadmin):
login   name    surname
admin   Chuck   Norris
user2   John    Cena
I am trying to get same output in php:
if ($stmt = $mysqli->prepare("SELECT * FROM vonline")) {
    $stmt->execute();
    $result = $stmt->get_result();
    echo "Online users: $stmt->num_rows"; // This shows "0"
    while ($row = $result->fetch_array(MYSQLI_NUM)) {
        echo "Login: $row[1] Name: $row[1] Surname: $row[2]";
    }
} else {
    echo "Select Error";
}
Why get no results, num_rows returns 0.
The code above works perfectly for selecting data from other tables, but not for this one.
 
     
    