andrewgarn Posted June 23, 2008 Share Posted June 23, 2008 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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/ Share on other sites More sharing options...
grlayouts Posted June 23, 2008 Share Posted June 23, 2008 something simple would be like take away timenow from time logged in then do a simple if time <300 print user. Link to comment https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572431 Share on other sites More sharing options...
Jabop Posted June 23, 2008 Share Posted June 23, 2008 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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572434 Share on other sites More sharing options...
andrewgarn Posted June 23, 2008 Author Share Posted June 23, 2008 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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572445 Share on other sites More sharing options...
Jabop Posted June 23, 2008 Share Posted June 23, 2008 <?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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572448 Share on other sites More sharing options...
andrewgarn Posted June 23, 2008 Author Share Posted June 23, 2008 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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572459 Share on other sites More sharing options...
Jabop Posted June 23, 2008 Share Posted June 23, 2008 <?php $date=strtotime($lastlogin); ?> Link to comment https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572465 Share on other sites More sharing options...
andrewgarn Posted June 23, 2008 Author Share Posted June 23, 2008 <?php $date=strtotime($lastlogin); ?> gives: 1214241476? Link to comment https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572470 Share on other sites More sharing options...
plutomed Posted June 23, 2008 Share Posted June 23, 2008 One problem is your date syntax you need a capital Y in stead of a lowercase one. Link to comment https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572485 Share on other sites More sharing options...
andrewgarn Posted June 23, 2008 Author Share Posted June 23, 2008 One problem is your date syntax you need a capital Y in stead of a lowercase one. That didnt change the results Link to comment https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572488 Share on other sites More sharing options...
Jabop Posted June 23, 2008 Share Posted June 23, 2008 Yeah... that is right andrew. It should be that number. $now=strtotime(NOW); So, $date>$now etc Link to comment https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572497 Share on other sites More sharing options...
andrewgarn Posted June 23, 2008 Author Share Posted June 23, 2008 Yeah... that is right andrew. It should be that number. $now=strtotime(NOW); So, $date>$now etc That gives time in seconds? Thanks for your help, again. works now Link to comment https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572510 Share on other sites More sharing options...
Jabop Posted June 23, 2008 Share Posted June 23, 2008 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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572512 Share on other sites More sharing options...
andrewgarn Posted June 23, 2008 Author Share Posted June 23, 2008 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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572529 Share on other sites More sharing options...
andrewgarn Posted June 23, 2008 Author Share Posted June 23, 2008 <?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 https://forums.phpfreaks.com/topic/111534-solved-recently-active-users/#findComment-572667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.