Jump to content

Recommended Posts

ok, i am trying to create an active users script for my site, i already have a system in place so that every place you visit it logs your session name and the time, i have mysql select users active in the last 15 minutes without a problem. The thing is there are multiple entries where the same session id is up, just different places and times. I want it to only display there name once even if they are in there 15 times. I want the ones it selects to be the most recent, time wise.

Link to comment
https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/
Share on other sites

Each individual person that visits your site can have their <b>own</b> session...so you would still know how much traffic your site has. You just won't know how much a specific person has clicked, I don't know if you want that or not.

if its for members, as in people registed on your website, id just have a last active time feild in your database.... in this format

date("YmdHi");

 

now add 15 or something to it

 

this will return the yearmonthdayhourminute

eg. 200704032241

 

get the current time, with this format again then if(date(YmdHi<last active feild){ do the shit

full code:

<?php
$time = date("YmdHi");
$query = mysql_query("SELECT * FROM yourtable WHERE lastactive > $time"); //edit this to suit you
$row = mysql_fetch_array($query));
$number = mysql_num_rows($query); //number of people online

echo "number of people active in last 15 minutes: $number<br /><br />
people active in last 15 minutes:<br/>
$row[username]";
?>

OK, can anyone tell me how to do what i am asking, please stop telling me how to rewrite my system, can anyone just answer my question? All i want to do is make a result with multiple rows use the latest row for a field. Thank you, but again my system is final, i will not rewrite it, so could anyone help me do something like this:

 

EXAPLE:

Pyro 12545

Pyro 12546

Pyro 12547

Matt 12548

Matt 12547

 

RESULT:

Pyro 12547

Matt 12548

your doing it wrong, if youve got it in a seperate table:

mysql_query(SELECT * FROM your table);

 

now that yue got all the results, to upate it use

$amount = mysql_num_row(mysql_query(SELECT * FROM your table WHERE username=username));

if($amount>1){ update the value }else{ insert all infromation..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.