i want a code 4 a block like this:
member last online
------------------
member1 03:30
member2 03:12
member3 02:45
can any give me this code ??
i hope u unsterstand me ... my english is not so good :tickedoff:
How many? Do you want to include the ones who are currently online as well?
include (not sure, but its ok) and display the 10 last members
To go into a php block:
global $db_prefix, $scripturl;
// How many do you want to display?
$limit = 10;
// Adjustment to time -- If the time displayed is not correct, enter how many hours it needs to be adjusted by.
$time_adjust = 0;
$result = db_query("SELECT realName, ID_MEMBER, lastLogin
FROM {$db_prefix}members
ORDER BY lastLogin DESC
LIMIT $limit", __FILE__, __LINE__);
echo '<table>';
while ($row = mysql_fetch_assoc($result)){
$time = $row['lastLogin'] + ($time_adjust * 3600);
echo '
<tr>
<td><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></td>
<td>' . date('H:i',$time) . '</td>
</tr>';
}
echo '</table>';
mysql_free_result($result);
Added a variable -- $time_adjust -- to allow admins to adjust the time displayed.
absolut great !!! ok i have a elvispresley-site and he said:
THANK YOU VERY MUCH !! :coolsmiley:
Fast $foo from JPDeni. :o
Good work- and much better than what I had come up with initially.
::)
:) Glad it worked for you, whitesox.
Thanks, Ianedres. There's almost always a number of ways to do something.
ok i think this is a good code, can any move 2 codesnippets ...
Quotecan any move 2 codesnippets
I don't know what that means.
sry i mean can any move this thread to the forum "block code snippets"
sry 4 my bad english ???
I see. :-)
I'll change the topic title and move it.
perfect and thx again :-)
not really perfect: i want the time +1 , can you help me?
this code show not correct time (i think), i need time for germany (i think is gmt+1).
can any tell me how i change the code (i think with mktime, but i dont know how) ?
I changed the original code. I added in a place where you can enter the number of hours you want the time adjusted by.
thank you very much!
:)
so you have a demo so we can see how it works?
Who are you asking? I don't because I don't want to put it on my live site and I don't have any real members of my testing site. If whitesox wants to give a link to his site, it would be nice.
yes why not. here is my site - but its german :-)
http://www.elvisonline.de
and see screenshot :up:
Quote from: JPDeni on May 17, 2009, 02:11:49 AM
Who are you asking? I don't because I don't want to put it on my live site and I don't have any real members of my testing site. If whitesox wants to give a link to his site, it would be nice.
sorry, I forgot to put whitesox name whom I was asking..... thx WhiteSox. I think I can use that block too. MORE great work from JDP!!
yes absolute great work from JPDeni :up:
Much $foo from this JPDeni, yes. :coolsmiley:
:up: great job
only one question - is it possible to adjust the font size ?
we need it smaller than now ???
You can use the already-defined css "smalltext" size:
echo '<table class="smalltext">';
Or you can alter the font size just like you would on a regular html page, with inline css.
This is great, but if the users time goes back past 24 hours, the block shows no indicator of that.
example:
ElectricSquid 00:16
Cultural Infidel 22:46
DUFF 22:02
Project84 21:01
HBMT 18:25
phoenix 18:24
mopar65pa 17:58
Bogie 01:07
dodgeman 22:44 <-----<< here's the flip into yesterday
intenseimages 08:52
Night Hawk 12:09
Raminator 01:18
BigDaddy_HD 21:05 <-----<< two days ago
+3$+ 20:58
dexetr30 11:49
D-100 17:46
3jvj 00:28
okiedrew 23:02 <-----<< three days ago
Mike_Mandaville 20:42
I think this mod would be GREAT if it showed the date as well
example:
ElectricSquid 00:16 6/10
Cultural Infidel 22:46 6/9
DUFF 22:02 6/9
Project84 21:01 6/9
HBMT 18:25 6/9
phoenix 18:24 6/9
mopar65pa 17:58 6/9
Bogie 01:07 6/9
dodgeman 22:44 6/8
intenseimages 08:52 6/8
Night Hawk 12:09 6/8
Raminator 01:18 6/8
BigDaddy_HD 21:05 6/7
+3$+ 20:58 6/7
dexetr30 11:49 6/7
D-100 17:46 6/7
3jvj 00:28 6/7
okiedrew 23:02 6/6
Mike_Mandaville 20:42 6/6
Just change the date format in this part:
date('H:i',$time)
If you don't know how to adjust the date format, see this page (http://www.php.net/manual/en/function.date.php).
Thankyou.
Teach a man to fish, he eats for a lifetime, LOL
Quote from: ∑Ã,£â„“Ã,¢ââ,¬Â Ã,®Ã,¡Ã,¢ Ã,§á»£Ã...³Ã,¡Ã,,‘ on June 10, 2009, 05:46:33 AM
Thankyou.
Teach a man to fish, he eats for a lifetime, LOL
/me Points at sig
:)
Quote from: IchBinâ„¢ on June 10, 2009, 06:09:25 AM
/me Points at sig
:)
Yup, I've come a long way from what you taught me a few years ago.
Quote from: JPDeni on June 10, 2009, 05:41:31 AM
Just change the date format in this part:
date('H:i',$time)
If you don't know how to adjust the date format, see this page (http://www.php.net/manual/en/function.date.php).
COOL, I have it looking good for my admin uses.
Using the "smalltext" class on the table, I have...
<tr>
<td align="left"><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></td>
<td align="center" style="padding-right: 0px;">' . date('n/j',$time) . '</td>
<td align="right">' . date('g:i a',$time) . '</td>
</tr>
This gives the date and the time with am/pm and it all lines up nicely down the rows
( 6/10 1:39 am)
One last question, how do I go about making the admin invisible to users on this list?
I know it's something like...
if (empty($context['admin']))
- or -
if (empty($context['user']['is_admin']))
...or something like that, but I don't know where to take it from there.
YEA!!
I think I figured out the answer to my question.
I used this bit of code as the if/else statement (for lack of a better term)
echo '<table width="100%" class="smalltext">';
while ($row = mysql_fetch_assoc($result)){
$time = $row['lastLogin'] + ($time_adjust * 3600);
echo '
<tr>
';
if ($row['ID_MEMBER'] == 1 )
echo '';
else
echo '
<td align="left"><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></td>
<td align="center" style="padding-right: 0px;">' . date('n/j',$time) . '</td>
<td align="right">' . date('g:i a',$time) . '</td>
</tr>';
}
echo '</table>';
mysql_free_result($result);
... and my Admin username disappeared from the list without producing any errors in the error log or parse errors (the dreaded white screen of shame and doom).
Could one of you take a quick look over that if/else and tell me if it's truly correct?
Thanks!!
There's a number of ways to do it. If it was me, instead of
if ($row['ID_MEMBER'] == 1 )
echo '';
else
I would use
if ($row['ID_MEMBER'] <> 1 )
Cool that you worked it out for yourself, though. :up:
Thanks JPDeni, I was looking for something like this. Great Snippet