|
|
It appears you are using a browser that is not based on Internet Explorer, this means you are not viewing the web as good as you should be. Other browsers might try to immitate Internet Explorer, but none can parse the web as it should like Internet Explorer can. So view the web as it was meant to be with Avant Browser!
|
| |
|
|
All times are GMT - 5 Hours
|
|
 |
Mon Mar 20, 2006 5:17 pm |
 |
Author |
Message |
found it  Site Supporter

Joined: 07 Jan 2005 Posts: 41 Words Posted: 2,687 Average Post: 65.54
|
| Post subject: [SOLVED]2 random users |
|
|
Hi
I am trying to get 2 random users to show up on my index page...I have managed to get one to work using some code that i found for a mod...is there anyway possible that you can get more than one random user showing..
Basically so you have 2 users with differnet names that change after each refresh....with their avatars......
here is the code I have managed to fid.....
| Code: | $sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_active = '1'
AND user_id <> " . ANONYMOUS . "
ORDER BY RAND() LIMIT 3";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query database for random user data.', '', __LINE__, __FILE__, $sql);
}
return ( $row = $db->sql_fetchrow($result) ) ? $row : false;
} |
Any help would be greatly appreciated...
Last edited by found it on Mon Mar 27, 2006 2:21 pm; edited 1 time in total |
|
| Post #1 |
|
|
 |
Mon Mar 20, 2006 7:48 pm |
 |
 |
Tue Mar 21, 2006 4:51 am |
 |
Author |
Message |
found it  Site Supporter

Joined: 07 Jan 2005 Posts: 41 Words Posted: 2,687 Average Post: 65.54
|
| Post subject: |
|
|
Hi
basically name then name then name...but showing different users each time
so it would be
test1, test2, test3
not test1, test1, test2 if you get what I mean
I have managed to get the avatar to work with users as well but I dont know how complicated that would be when having more than one random member...
Thanks for the reply |
|
| Post #3 |
|
|
 |
Tue Mar 21, 2006 5:17 am |
 |
 |
Tue Mar 21, 2006 5:24 am |
 |
Author |
Message |
found it  Site Supporter

Joined: 07 Jan 2005 Posts: 41 Words Posted: 2,687 Average Post: 65.54
|
| Post subject: |
|
|
Here is my array at present I for got to add that but
| Code: | $template->assign_vars(array(
'RANDOM_NAME' => $random_name,
|
and in my template file I have
so if i change the bit you say what would i place in the array....sorry whoosh over my heads alot of this
 |
|
| Post #5 |
|
|
 |
Tue Mar 21, 2006 6:29 pm |
 |
 |
Tue Mar 21, 2006 7:46 pm |
 |
 |
Wed Mar 22, 2006 7:48 am |
 |
Author |
Message |
found it  Site Supporter

Joined: 07 Jan 2005 Posts: 41 Words Posted: 2,687 Average Post: 65.54
|
| Post subject: |
|
|
Hi
after doing some searching i atually found the mod that this code originally came from.......
| Code: | #
#-----[ OPEN ]-------------------------------------
#
index.php
#
#-----[ FIND ]-------------------------------------
#
$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);
#
#-----[ AFTER, ADD ]-------------------------------------
#
// MOD - RANDOM USER MOD - AbelaJohnB
function random_user()
{
global $db;
$sql = "SELECT user_id, username
FROM " . USERS_TABLE . "
WHERE user_active = '1'
AND user_id <> " . ANONYMOUS . "
ORDER BY RAND() LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query random user data.', '', __LINE__, __FILE__, $sql);
}
return ( $row = $db->sql_fetchrow($result) ) ? $row : false;
}
$profiledata = random_user();
$random_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=".$profiledata['user_id']."") . '">'. $profiledata['username']. '</a>';
// MOD - RANDOM USER MOD - AbelaJohnB
#
#-----[ FIND ]-------------------------------------
#
'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
#
#-----[ BEFORE, ADD ]-------------------------------------
#
// MOD - RANDOM USER MOD - AbelaJohnB
'L_RANDOM_USER' => $lang['Random_user'],
'RANDOM_USER_LINK' => $random_link,
// MOD - RANDOM USER MOD - AbelaJohnB
#
#-----[ OPEN ]-------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]-------------------------------------
#
<td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span>
#
#-----[ IN-LINE FIND ]-------------------------------------
#
{NEWEST_USER}
#
#-----[ IN-LINE AFTER, ADD ]-------------------------------------
#
<br />{L_RANDOM_USER} {RANDOM_USER_LINK}<br />
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Newest_user'] = 'The newest registered user is <b>%s%s%s</b>'; // a href, username, /a
#
#-----[ AFTER, ADD ]------------------------------------------
#
// MOD - RANDOM USER MOD - AbelaJohnB
$lang['Random_user'] = 'A random user is: ';
// MOD - RANDOM USER MOD - AbelaJohnB
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ |
thats what i was using I didnt realise it was already a mod for one random user......using that code can you make 2 or 3.....?
also for the avatar i added
| Code: | if ( $profiledata['user_avatar_type'] )
{
switch( $profiledata['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
$random_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" width="120" height="80" title="" border="0" />' : '';
break;
case USER_AVATAR_REMOTE:
$random_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" title="" border="0" />' : '';
break;
case USER_AVATAR_GALLERY:
$random_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" title="" border="0" />' : '';
break;
}
}
// Shows default avatar, if no avatar
else if ( empty($user_avatar) )
{
$random_avatar = '<img src="images/no_avatar.gif" alt="No Picture Available" height="80" width="80" border="0" />';
} |
Thanks for any help....[/code] |
|
| Post #8 |
|
|
 |
Mon Mar 27, 2006 2:20 pm |
 |
 |
Mon Mar 27, 2006 4:55 pm |
 |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
Protected by phpBB Security © phpBB-TweakS phpBB Security Has Blocked 3,237 Exploit Attempts.
· Archive · Sitemap: Index · Sitemap: Forums · Sitemap: Topics · Sitemap: Posts ·
:: [ Load Time: 2.9 Seconds ] :: [ 29 Queries ] :: [ 2,977 Page(s) Viewed Today ] :: :: [ Todays Queries: 84,685 ] :: [ Highest Load: 1,396,429 Queries On May. 08, 2007 ] :: :: [ SQL Load: 59% Time: 1.7 ] :: [ PHP Load: 41% Time: 1.2 ] :: [ Debug: On ] :: [ GZIP: Enabled ] :: :: The server last rebooted 72 days, 6 hours, 43 minutes, 0 seconds ago. ::
|
|
|