Pyro4816 Posted April 3, 2007 Share Posted April 3, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/ Share on other sites More sharing options...
pocobueno1388 Posted April 3, 2007 Share Posted April 3, 2007 Instead of creating a <b>new</b> session everytime they click, why not just <b>update</b> it? Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220677 Share on other sites More sharing options...
Pyro4816 Posted April 3, 2007 Author Share Posted April 3, 2007 Well, it's more of a traffic tracking system, updating it is not the way for me to go at the moment, thank you for the thought tho. Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220679 Share on other sites More sharing options...
pocobueno1388 Posted April 3, 2007 Share Posted April 3, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220682 Share on other sites More sharing options...
Pyro4816 Posted April 3, 2007 Author Share Posted April 3, 2007 Not trying to be rude, but could we stick to topic, i know what i built my system for and it serves it's purpose just fine. Thank you for the thought though. Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220684 Share on other sites More sharing options...
Ronno Posted April 3, 2007 Share Posted April 3, 2007 I'm pretty new to php and mysql, that being said why can't you just do something like the following? select distinct session from ... Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220685 Share on other sites More sharing options...
Pyro4816 Posted April 3, 2007 Author Share Posted April 3, 2007 im not sure what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220724 Share on other sites More sharing options...
only one Posted April 3, 2007 Share Posted April 3, 2007 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]"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220729 Share on other sites More sharing options...
Pyro4816 Posted April 3, 2007 Author Share Posted April 3, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220739 Share on other sites More sharing options...
sasa Posted April 3, 2007 Share Posted April 3, 2007 SELECT name, MAX(number) FROM table_name GROUP BY name Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220740 Share on other sites More sharing options...
Pyro4816 Posted April 3, 2007 Author Share Posted April 3, 2007 is there a way to use that to get multiple results? Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220746 Share on other sites More sharing options...
Pyro4816 Posted April 4, 2007 Author Share Posted April 4, 2007 anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220866 Share on other sites More sharing options...
only one Posted April 4, 2007 Share Posted April 4, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/45452-need-help-with-an-active-user-script/#findComment-220981 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.