runnerjp Posted October 8, 2008 Share Posted October 8, 2008 i have five forum pages http://www.site.com/members/index.php?page=forum&forum=general http://www.site.com/members/index.php?page=forum&forum=races http://www.site.com/members/index.php?page=forum&forum=training http://www.site.com/members/index.php?page=forum&forum=qa http://www.site.com/members/index.php?page=forum&forum=injuries i currently use this code to find out if a user is on a page <? $result = mysql_query("SELECT * FROM useronline WHERE(file='http://www.site.com/members/index.php?page=forum&forum=$forum')"); while($row = mysql_fetch_array( $result )) { $last_active = time() - $row['timestamp']; $onlineuser = $row['user']; } if($last_active < 300) { echo $onlineuser; } ?> is there away i can make it so it find everyone one them links... Quote Link to comment https://forums.phpfreaks.com/topic/127555-finding-out-users-on-pages/ Share on other sites More sharing options...
sKunKbad Posted October 8, 2008 Share Posted October 8, 2008 is there away i can make it so it find everyone one them links... Please rephrase the question. This makes no sense at all. Quote Link to comment https://forums.phpfreaks.com/topic/127555-finding-out-users-on-pages/#findComment-659963 Share on other sites More sharing options...
runnerjp Posted October 8, 2008 Author Share Posted October 8, 2008 ok on all my pages i record what user is viewing them... the time they viewed them and so on like this <?php $timestamp = time(); $timeout = $timestamp - 180; $username = get_username($_SESSION['user_id']); function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":" . $_SERVER["SERVER_PORT"]); return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } $filename = (selfURL()); //Insert User $insert = mysql_query("REPLACE INTO `useronline` SET `timestamp`='$timestamp', `ip`='" . $_SERVER['REMOTE_ADDR'] . "', `file`='$filename',`user`='$username',`user_id`='" . $_SESSION['user_id'] . "'") or die(mysql_error()); ?> so what i want to do is from file where the page is stored of the users currently viewed page on the site is pull how many users are on all the pages i mentioned above... example admin,runnerjp and skunkbad are on the forum Quote Link to comment https://forums.phpfreaks.com/topic/127555-finding-out-users-on-pages/#findComment-659993 Share on other sites More sharing options...
sKunKbad Posted October 8, 2008 Share Posted October 8, 2008 most sites that track users and display who is online show who is online every 5 minutes or so, so you could do the same if you search your database for users who have timestamps that are within a range of the current time to the current time minus 5 minutes. Your query would be something like: "select * from userLog where lastPageLoad >= ($currentTime - 300)" THIS IS OBVIOUSLY NOT A REAL SQL STATEMENT, but with some work on your part, you could make an sql statement that does work, and displays who is online semi-accurately. Quote Link to comment https://forums.phpfreaks.com/topic/127555-finding-out-users-on-pages/#findComment-660096 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.