Jump to content

show who is online


Recommended Posts

ok so I have this code

$_SESSION['username'] = "johndoe" // Must be already set

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd" >

<title>Sample Chat Application</title>
body {
background-color: #eeeeee;
margin:0 auto;
font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;

<link type="text/css" rel="stylesheet" media="all" href="css/chat.css" />
<link type="text/css" rel="stylesheet" media="all" href="css/screen.css" />

<!--[if lte IE 7]>
<link type="text/css" rel="stylesheet" media="all" href="css/screen_ie.css" />

<div id="main_container">
<a href="javascript:void(0)" onClick="javascript:chatWith('janedoe')">Chat With Jane Doe</a>
<a href="javascript:void(0)" onClick="javascript:chatWith('babydoe')">Chat With Baby Doe</a>


<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/chat.js"></script>



how can I make it so that it only shows a link to chat with whoever is online?  and how do I make it so that the link will go to users in a database.........username........and name(in database)  does this make a little bit of sense or any at all?

Link to comment
Share on other sites

I'm not going to write the code for you, but I will explain how to do it.


Who's online is entirely dependent on who was last seen online in the last say 5 minutes. So what you need to do is add a timestamp in your database that updates everything a page is updated. You could also use a file for this.


Then, when you build your list of who's online, simply search the database for TS where time is less greater than now - 5 minutes.

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.