TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 18, 2024, 01:21:40 PM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 112
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 44
  • Total: 44

[Block] Random User Block - New

Started by JayBachatero, October 22, 2007, 07:11:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wilsy

JPDeni is a genius - thank you so much!

Regards,

Wilsy.

alving

i tried using this code that displays a generic image for members without avatar but there are times that the generic image is not being displayed for some members without avatar..  any help please..

scope

I was curious abou thow to change it to display people that haven't not logged in within a certain amount of days, Is there a way to do this?

alving

i'm trying to get random members from a particular post group, but everytime i put in the group number, the script displays nothing..  i dont know what i'm doing wrong..

help please.  thanks in advance

JayBachatero

Change

$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';

to

$group_clause = empty($groups) ? '1' : 'ID_POST_GROUP IN(' . implode(',', $groups) . ')';

alving

thanks jay!  it's working now..

GKDantas

Any chance to a way to control how many lines in the table? I would like to have the block without the scrolling. Something like a 3X2 table in the block. Can someone help with this?

JPDeni


global $db_prefix, $memberContext;

// How many members we want?
$members_limit = 6;

// How many to display per row? Should be a factor of the $members_limit
$per_row = 3;

// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';

$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';

// Lets get the ID's of the members we want.
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE $group_clause
ORDER BY RAND()
LIMIT $members_limit", __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);

// Load the data for these members.
loadMemberData($members);

// Now get the context.
foreach ($members as $member)
loadMemberContext($member);

$display = 0;
echo '
<table ALIGN="center">
<tr>';
foreach ($memberContext as $member)
{
++$display;
echo '
<td><center>
', empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
', $member['link'], '
</center></td>';
if ($display == $per_row) {
echo '
</tr>
<tr>
';
$display = 0;
}
}
echo '
</tr>
</table>';


I've added another variable $per_row that you can set to make your table.

I didn't test it, but I'm pretty sure it wil work.

GKDantas

Wow! That was fast! Works like a charm, but it counts 1 more user: if you set to 5 it will show 6... no problem at all.
Can I ask you a little more help? Theres almost the same block for the newest users, you asked me about what I want and this is really what I would like to have for the newest block.

http://www.tinyportal.net/index.php/topic,7737.140.html