
February 26th, 2007
12:06 AM
Neverside Newbie
Status: Offline!
Displaying a userlist in my chat
I'm building a small php chat and i'm now trying to make a userlist. Problem is, I can't find a way to make the users work without a mysql database... which is what I want.
as of right now, I can display the users.. but everytime the page refreshes, they reappear!!! (because I have a meta refresh in users.php)
if (isset($user)){ // user is $_SESSION['username']
$fileN="users.php";
$file = fopen($fileN,"a";
$txt = fwrite($file,"$user<br>";
fclose($file);
}
what i'm trying to do is take each user, put them in an array, and after that, make a foreach so each user get displayed. I also want to remove a user from the list when he hasn't typed anything for the past 5 minutes.. but i'm stuck!!!
Any help would be appreciated!

February 26th, 2007
05:53 PM
Neverside Newbie
Status: Offline!
php really isnt suited to chat apps, I know its not what you want to hear but the whole thing is a hack.
___________________
Glasgow SEO

February 28th, 2007
05:46 AM
God's Son
Status: Offline!
use a timestamp
___________________
"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

February 28th, 2007
05:58 PM
funny and cheeky
Status: Offline!
Use the date function to register the time he last typed. You'll need some javascript though definately because there's no way the server can monitor what a client is doing. you could benfit from using AJAX (asynchronous Javascript and XML) or AJAP ( asynchronous javascript and php) if cant be arsed with xml (very easy though like html). You willl also need to use the onchange event on the textbox the user typing in.
Others may think I dont know what am talking about and there's no such thing as AJAP.
THERE IS NOW!!
http://www.phpit.net/article/ajax-php-without-xmlhttprequest
This site takes the idea of AJAX and changes it in such a way that u dont use xml. Instead u use php hence AJAP
The whole point of using AJAX/AJAP is so that u dont need your meta refresh it does it automatically and the user doesn't see the page refresh. So it works similar to msn when the user list is refreshed.
Mysql is a simple database anyone could learn it. SQL statements you use to query the database is litterally plain english. PHP has built in functions for mysql so they're hand in hand.
I suggest you do some research on what I've mensioned and see if you formulate a algorithum. It's good pratice and it pays fairly well if you consider youself as a developer. I'm afriad this is what programming is all about.
Last edited by schoi, February 28th, 2007 07:01 PM (Edited 2 times)