Jump to content

[SOLVED] Recently active users


andrewgarn

Recommended Posts

I have a login system, which stores the login time into a table as last login.

 

What i want to do is display users who logged in recently, or are using the site currently at the bottom of the page.

 

How would i go about doing this? It might use the last login info it might not, any ideas?

 

EDIT:

 

Also as a further question: Is it possible to put conditional formatting in CSS? I want numbers inside a div to be red if they are negative and green if they are positive

 

Thanks

Link to comment
Share on other sites

Regarding the CSS styling:

 

<?php

if ($this==$that) { $class="red"; }
elseif ($this==$that2) { $class="orange"; }
elseif ($this==$that3) { $class="yellow"; }

echo '<span style="font-color:'.$class.';">Hey I\'m a different color font</span>';
?>

Link to comment
Share on other sites

Regarding the CSS styling:

 

<?php

if ($this==$that) { $class="red"; }
elseif ($this==$that2) { $class="orange"; }
elseif ($this==$that3) { $class="yellow"; }

echo '<span style="font-color:'.$class.';">Hey I\'m a different color font</span>';
?>

 

So youve done it in php instead? I would need if($var < 0) ( $class="red"; )

 

can i put that span around 50 lines of code or need to be individually declared for each echo?

Link to comment
Share on other sites

<?php

if ($this==$that) { $class="red"; }
elseif ($this==$that2) { $class="orange"; }
elseif ($this==$that3) { $class="yellow"; }

// assuming you have enabled yourself to parse php within html files:
?>

There were <span style="<?=$class?>">AMOUNT</span> users online. Blah blah.

<?
// do more php stuff, etc.
?>

Link to comment
Share on other sites

something simple would be like

 

take away timenow from time logged in then do a simple if time <300 print user.

 

In the database i have lastlogin stored as Datetime - 2008-06-23 20:17:56

 

then i retrieve the time using:

 

$date = date("y-m-d H:i:s");

 

but i minus one from the other i get -2000, why?

Link to comment
Share on other sites

It's time in seconds from the unix epoch. So you can compare all of your times with that.

 

<?php

$date=strtotime($lastupdated);

$now=strtotime(NOW);

if ($date>$now) {
      // do this
} else {
     // do that
}

?>

Link to comment
Share on other sites

It's time in seconds from the unix epoch. So you can compare all of your times with that.

 

<?php

$date=strtotime($lastupdated);

$now=strtotime(NOW);

if ($date>$now) {
      // do this
} else {
     // do that
}

?>

 

My requirement was just to show users active in last certain amount of time, so this fulfils it perfectly :)

Link to comment
Share on other sites

<?php

if ($this==$that) { $class="red"; }
elseif ($this==$that2) { $class="orange"; }
elseif ($this==$that3) { $class="yellow"; }

// assuming you have enabled yourself to parse php within html files:
?>

There were <span style="<?=$class?>">AMOUNT</span> users online. Blah blah.

<?
// do more php stuff, etc.
?>

 

couldnt make it work :(

 

you mentioned something about php parsing html, how does it do that?

 

EDIT: nmind made it work using if statements in each class

Link to comment
Share on other sites

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.