Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2005, 09:09 AM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default latest user

Hi,

I'd like to display the latest 5 users who registered to my forum.
What do I have to edit please?

Thanks

any help?
Reply With Quote
  #2  
Old 05-28-2005, 02:43 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where do you want it displayed?
Off the top of my head, place something like in the file you want it:

PHP Code:
$newestmembers $DB_site->query("
    SELECT userid, username
    FROM user
    ORDER BY userid DESC
    LIMIT 5
"
);
$shownewest=$DB_site->fetch_array($newestmembers))
{
    
$counter++;
    
$newuserid $shownewest['userid'];
    
$newusername $shownewest['username'];
    
$newestbit .= "<a href=\"member.php?u=$newuserid\">$newusername</a>";
    if (
$counter 5)
    {
        
$newestbit .= ", ";
    }

Then place $newestbit in your template where you want it (it will list the last 5 users seperated by commas).
Reply With Quote
  #3  
Old 05-28-2005, 03:15 AM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think if you are going to use query instead of query_first you need to use 'while' like this:

PHP Code:
$newestmembers $DB_site->query(
    SELECT userid, username 
    FROM user 
    ORDER BY userid DESC 
    LIMIT 5 
"
); 
while (
$shownewest=$DB_site->fetch_array($newestmembers)) 

    
$counter++; 
    
$newuserid $shownewest['userid']; 
    
$newusername $shownewest['username']; 
    
$newestbit .= "<a href=\"member.php?u=$newuserid\">$newusername</a>"
    if (
$counter 5
    { 
        
$newestbit .= ", "
    } 

Reply With Quote
  #4  
Old 05-28-2005, 03:33 AM
N8's Avatar
N8 N8 is offline
 
Join Date: Dec 2004
Posts: 146
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm trying to add the joindate to this, but I'm not sure how format it to display.

heres the code:
Code:
$newestmembers = $DB_site->query(" 
    SELECT userid, username, joindate
    FROM user 
    ORDER BY userid DESC 
    LIMIT 20 
"); 
while ($shownewest=$DB_site->fetch_array($newestmembers)) 
{ 
    $counter++; 
    $newuserid = $shownewest['userid']; 
    $newusername = $shownewest['username']; 
    $newuserjoin = $shownewest['joindate']; 

    $newestbit .= "<a href=\"member.php?u=$newuserid\">$newusername</a> ($newuserjoin)"; 
    if ($counter < 20) 
    { 
        $newestbit .= "<br /> "; 
    } 
}
and heres what gets displayed:
Code:
Blue[sK] (1117254613)
ebad (1117254372)
123qwe (1117254139)
pointvu (1117253360)
lilbudbud03 (1117252790)
tugger9709 (1117252356)
TheCraftMaster10 (1117252283)
sonnie (1117251372)
hellohellorex (1117251360)
waterfall2cold (1117250130)
LonLey (1117249889)
eN.Banged (1117249323)
cornpops (1117248783)
mokodoko (1117248778)
pimpsta123 (1117248764)
g4it (1117248533)
ace2255 (1117248231)
thaphantomone (1117248186)
Masta-killa (1117248057)
aqz (1117247951)
Any ideas?
Reply With Quote
  #5  
Old 05-28-2005, 04:00 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to convert the time stamps.
Add something like
PHP Code:
$joindate date("F d @ g:i A T",$shownewest['joindate']); 
You can change the format easily enough (look here: http://ca3.php.net/date)



@eric: typo
Reply With Quote
  #6  
Old 05-28-2005, 04:27 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Another thing you may want to consider is to cache this info in the datastore to save on queries.

Amy
Reply With Quote
  #7  
Old 05-28-2005, 06:53 AM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TheSpecialist
Where do you want it displayed?

I want it to be displayed in the index.php so what code do I have to eliminate?
Thanks
Reply With Quote
  #8  
Old 05-29-2005, 12:52 AM
RapCapital RapCapital is offline
 
Join Date: Mar 2005
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I recomend installing the Stats Hack
Reply With Quote
  #9  
Old 05-29-2005, 05:58 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by RapCapital
I recomend installing the Stats Hack
Slight overkill for just the last 5 members.
Reply With Quote
  #10  
Old 05-29-2005, 07:05 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's the updated one with datastore

index.php:
Find:
PHP Code:
// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTA HERE... ### 
Above it, add:
PHP Code:
// Show 5 Newest Members //
$numbermembers vb_number_format($userstats['numbermembers']);

$newestmembers unserialize($datastore['newestmembers']);
foreach (
$newestmembers as $two)
{
    
$counter++;
    
$newuserid $two['userid'];
    
$newusername $two['username'];
    
$newestbit .= "<a href=\"member.php?$session['sessionurl']u=$newuserid\">$newusername</a>";
    if (
$counter 5)
    {
        
$newestbit .= ", ";
    }
}
// END Show 5 Newest Members // 
Find: (in $specialtemplates)
PHP Code:
'eventcache',
'mailqueue' 
Replace it with:
PHP Code:
'eventcache',
'mailqueue',
'newestmembers' 
In the FORUMHOME TEMPLATE, find:
HTML Code:
<div><phrase 1="member.php?$session[sessionurl]u=$newuserid" 2="$newusername">$vbphrase[welcome_to_our_newest_member_x]</phrase></div>
Replace it with:
HTML Code:
<div>Welcome to our newest members, $newestbit </div>
Cron file:
(newestmemberscron.php - put in /includes/cron)
PHP Code:
<?php

error_reporting
(E_ALL & ~E_NOTICE);

if (!
is_object($DB_site))
{
    exit;
}

$newestmembers $DB_site->query("
    SELECT userid, username
    FROM user
    ORDER BY userid DESC
    LIMIT 5
"
);
while(
$newestmemberss=$DB_site->fetch_array($newestmembers))
{   
$counter++;
    echo 
$counter;
    
$array[$counter] = $newestmemberss;
}

$fivenewestmembers addslashes(serialize($array));

// Update DataStore
$check $DB_site->query("
    SELECT *
    FROM datastore
    WHERE title='newestmembers'
"
);
if (
$DB_site->num_rows($check) == 0)
{
    
$insertdatastore $DB_site->query("
        INSERT INTO datastore
        (title, data)
        VALUES ('newestmembers', '
$fivenewestmembers')
    "
);
}
elseif (
$DB_site->num_rows($check) != 0)
{
    
$updatedatastore $DB_site->query("
        UPDATE datastore
        SET data='
$fivenewestmembers'
        WHERE title='newestmembers'
    "
);
}



?>
Be sure to add that file to scheduled tasks, and set the run date as often as you'd like (probably an hour to a day, up to you).

.. first time having to use datastore, hopefully it's somewhat right.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:26 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04142 seconds
  • Memory Usage 2,295KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_html
  • (8)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete