使用页面创建网站以显示在线用户,包括用户名和图片[关闭]

I am in the stages of the class diagram, I was creating the class diagram for a website I am planning to create. It was going fine until I reached the stage of wanting to have a web page that displayed the online users e.g. showing their username and profile picture of all online users. I am not sure on how I would do this, the image is of what I have so far. I would appreciate any help or guidance.

Here is my current class diagram http://imgur.com/sgjJwkc

You could also set up a column for user's status (logged in, logged out) and make it toggle between 0 (logged out) and 1 (logged in). You could update this information every 5 seconds (in the background of course) using an AJAX call. Something like this:

//JAVASCRIPT
<script>
    $(document).ready(function() {
        setInterval(function() {
            $.post('Path To PHP File', {x : Pass Variables, y: If You Want}, function(res)
                //Do something with the result (res)
            );
        }, 5000);
    });
</script>

//PHP FILE
<?php
//If you passed any variables to the script:
$x = $_POST['x'];
$y = $_POST['y'];

//Connect to your database
$dbConn = "I hope you're using PDO for this.";

//Create your query
$sql = "SELECT * FROM users WHERE status=1";
$res = $dbConn->prepare($sql);
$res->execute();

//Return/echo results
foreach($res as $x) {
    echo "<div id='useTheIdToStyleTheResults'>".$x['name']."</div>";
}
?>

res is whatever your php script returns. You can simply run an SQL query on your database in that script to get all users who are logged in and use a foreach() loop to return each item as an html div element. Style those elements to your liking and there you go. If you have questions, just ask!

EDIT:

After reading a little more of your question, SQL JOIN and UNION are a couple of concepts you might want to look into. http://www.w3schools.com/sql/sql_join.asp

EDIT #2:

//Define Variables
$hostname = '127.0.0.1';
$username = 'userName';
$password = 'passWord';
$dbname = 'database in use';

//Create Connection
try {
    $con = new PDO("mysql:host=$hostname;dbname=$dbname",$username,$password);
    $con->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
    //echo "Connected to database";  //Uncomment statement to the left to check for connection
} catch (PDOException $e) {
    print "Unable to connect: " . $e->getMessage();
    mysql_close($con);
    die();
}
?>

I would update a timestamp in the user's row every time they load a page and on the load of the online users I would check for timestamps that are fairly recent.

Pseudocode: SELECT username,avatar FROM users WHERE last_active >= time()-900;