phpBB-TweakS
 
Advanced Search
   
 
Home Downloads FAQ Register FAQ Memberlist Usergroups Ranks
 
 

Please help us to develop!

 
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!
         

phpBB-TweakS Forum Index Index Support [SOLVED]2 random users
Display posts from previous:   
Half Thread Topic  Fully Thread Topic  Download Topic
      All times are GMT - 5 Hours  
Post new topic  Reply to topic

Mon Mar 20, 2006 5:17 pm
Author Message
Cool found it Cool
Site Supporter
Site Supporter


Joined: 07 Jan 2005
Posts: 41
Words Posted: 2,687
Average Post: 65.54


Post subject: [SOLVED]2 random users Reply with quote

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
      Back To Top  

Mon Mar 20, 2006 7:48 pm
Author Message
aUsTiN
Webmaster
Webmaster


Usa Georgia

Joined: 05 Jan 2005
Posts: 3684
Words Posted: 144,671
Average Post: 39.27

Location: USA

Post subject: Reply with quote

How is the end result supposed to be?

Name, Name, Name, Etc..?
Post #2
      Back To Top  

Tue Mar 21, 2006 4:51 am
Author Message
Cool found it Cool
Site Supporter
Site Supporter


Joined: 07 Jan 2005
Posts: 41
Words Posted: 2,687
Average Post: 65.54


Post subject: Reply with quote

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
      Back To Top  

Tue Mar 21, 2006 5:17 am
Author Message
aUsTiN
Webmaster
Webmaster


Usa Georgia

Joined: 05 Jan 2005
Posts: 3684
Words Posted: 144,671
Average Post: 39.27

Location: USA

Post subject: Reply with quote

$row = $db->sql_fetchrow

needs to be

$row = $db->sql_fetchrowset

so it returns an array.
Post #4
      Back To Top  

Tue Mar 21, 2006 5:24 am
Author Message
Cool found it Cool
Site Supporter
Site Supporter


Joined: 07 Jan 2005
Posts: 41
Words Posted: 2,687
Average Post: 65.54


Post subject: Reply with quote

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

Code:
{RANDOM_NAME}


so if i change the bit you say what would i place in the array....sorry whoosh over my heads alot of this

Very Happy Very Happy
Post #5
      Back To Top  

Tue Mar 21, 2006 6:29 pm
Author Message
Cool found it Cool
Site Supporter
Site Supporter


Joined: 07 Jan 2005
Posts: 41
Words Posted: 2,687
Average Post: 65.54


Post subject: Reply with quote

ok well I a totally lost on this......


I thought it might be straight forward but i have just confused myself lol
Post #6
      Back To Top  

Tue Mar 21, 2006 7:46 pm
Author Message
aUsTiN
Webmaster
Webmaster


Usa Georgia

Joined: 05 Jan 2005
Posts: 3684
Words Posted: 144,671
Average Post: 39.27

Location: USA

Post subject: Reply with quote

I'd need to see the codes, all of them related to this, in the index.
Post #7
      Back To Top  

Wed Mar 22, 2006 7:48 am
Author Message
Cool found it Cool
Site Supporter
Site Supporter


Joined: 07 Jan 2005
Posts: 41
Words Posted: 2,687
Average Post: 65.54


Post subject: Reply with quote

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
      Back To Top  

Mon Mar 27, 2006 2:20 pm
Author Message
Cool found it Cool
Site Supporter
Site Supporter


Joined: 07 Jan 2005
Posts: 41
Words Posted: 2,687
Average Post: 65.54


Post subject: Reply with quote

I will mark this as solved as I have managed to figure it out....

just need to catch you online now to have a look at the other mod.... Very Happy
Post #9
      Back To Top  

Mon Mar 27, 2006 4:55 pm
Author Message
aUsTiN
Webmaster
Webmaster


Usa Georgia

Joined: 05 Jan 2005
Posts: 3684
Words Posted: 144,671
Average Post: 39.27

Location: USA

Post subject: Reply with quote

Sorry, this topic got lost for me, glad you figured it out tho.
Post #10
      Back To Top  

 
         

Post new topic  Reply to topic

phpBB-TweakS Forum Index Index Support [SOLVED]2 random users
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


      Back To Top  

Page 1 of 1
Jump to:  
 
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.8 Seconds ] :: [ 29 Queries ] :: [ 1,464 Page(s) Viewed Today ] ::
:: [ Todays Queries: 41,113 ] :: [ Highest Load: 1,396,429 Queries On May. 08, 2007 ] ::
:: [ SQL Load: 60% Time: 1.7 ] :: [ PHP Load: 40% Time: 1.1 ] :: [ Debug: On ] :: [ GZIP: Enabled ] ::
:: The server last rebooted 79 days, 19 hours, 27 minutes, 13 seconds ago. ::

The phpBB[Network]!
       
Powered by phpBB 2.0.* © 2001, 2002 phpBB Group
Avalanche style by What Is Real © 2004