searls03 Posted July 16, 2011 Share Posted July 16, 2011 ok so I have this code <?php session_start(); $_SESSION['username'] = "johndoe" // Must be already set ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd" > <html> <head> <title>Sample Chat Application</title> <style> body { background-color: #eeeeee; padding:0; margin:0 auto; font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size:11px; } </style> <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" /> <![endif]--> </head> <body> <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> <!-- YOUR BODY HERE --> </div> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/chat.js"></script> </body> </html> 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? Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted July 17, 2011 Share Posted July 17, 2011 i don't know if someone can come up with better solution. but it seems like you have to save anyone who is online in your database, re-check and connect each online people. Quote Link to comment Share on other sites More sharing options...
teynon Posted July 17, 2011 Share Posted July 17, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.