Jump to content

[SOLVED] showing users on my page..


runnerjp

Recommended Posts

ok when storing the page the users are on it could look like this

 

index.php?page=message&forum=general&id=278&pagenum=last

or

index.php?page=message&forum=general&id=278

 

how could i display it so it could fin either in the query... would it be

 

'http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$forumpostid%'

Link to comment
https://forums.phpfreaks.com/topic/131531-solved-showing-users-on-my-page/
Share on other sites

my whole code is..

 

getitng the users stuff

<?php
$timestamp = time();
$timeout = $timestamp - 180;



$MyURL = selfURL(0);

function selfURL() {
        
  $protocol = ($_SERVER["HTTPS"] == "on") ? 'https' : 'http';
  $port = (($_SERVER["SERVER_PORT"] == "80") || ($_SERVER["SERVER_PORT"] == "443")) ? '' : ':' . $_SERVER["SERVER_PORT"];
  return $protocol . '://' . $_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}

$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()); ?>

 

and trying to show users on the page

 

<?php
$getusersonline="SELECT user_id,user FROM useronline 
   WHERE 
file = 'http://www.runningprofiles.com/members/index.php?page=message&forum=$forum&id=$forumpostid%' AND
  timestamp > " . (time() - 900) ; //grab from sql users on in last 15 minutes
$getusersonline2=mysql_query($getusersonline) or die("Could not get users");
$num=mysql_num_rows($getusersonline2);

echo "$forumpostid <b>There " . ($num != 1 ? "are" : "is") . " $num user" . ($num != 1 ? "s" : "") . " currently viewing the $forum board: </B>";

$tmp = array();
while($getusersonline3=mysql_fetch_array($getusersonline2))
{
  $tmp[] = "<A href='$getusersonline3[user]'>$getusersonline3[user]</a>";
}
echo implode(',',$tmp);
?>        

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.