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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2006, 04:34 AM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Small problem with LIMIT

I'm trying to get the last six members to join my forums to show up on the forum home.. I have the basic idea working now, but for some reason the LIMIT isn't working for me.. It's only returning one result.. AKA the last registered member, rather than the last six.

PHP Code:
require_once(DIR '/includes/functions_user.php');

$newest_members_query "SELECT userid, username, joindate
    FROM " 
TABLE_PREFIX "user
    ORDER BY userid DESC
    LIMIT 6"
;

$new_members $vbulletin->db->query_first($newest_members_query);

if(
$new_members[userid]){

    
$new_members[avatarurl] = fetch_avatar_url($new_members[userid]);
    
    if (!
$new_members[avatarurl]) {
    
        
$new_members[avatarurl] = $stylevar['imgdir_misc'] . '/noavatar.gif';
        
    } else {
    
        
$new_members[avatarurl] = $vbulletin->options['bburl'] . '/' $new_members[avatarurl][0];
        
    }
}

eval(
'$newest_members .= "' fetch_template('newest_members') . '";'); 
Any ideas? I'm stumped. :ermm:
Thanks,
Reply With Quote
  #2  
Old 03-02-2006, 07:37 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$new_members $vbulletin->db->query_first($newest_members_query); 
query_first will only retrieve 1 row.
You will need to use query_read, and then a while loop with fetch_array to loop through the results.
Reply With Quote
  #3  
Old 03-02-2006, 03:49 PM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, I see..

Okay, I tried this new approach out but I'm still getting only one result (I have two registered users right now as I'm developing the site..), only user id2 is showing up..

PHP Code:
require_once(DIR '/includes/functions_user.php');

// Gather the six newest members to join
$newest_members $vbulletin->db->query_read("SELECT userid, username, joindate
    FROM " 
TABLE_PREFIX "user
    ORDER BY userid DESC
    LIMIT 6"
);

while (
$new_members $vbulletin->db->fetch_array($newest_members))
{

    
// Get users avatar
    
if($new_members[userid])
    {
        
$new_members[avatarurl] = fetch_avatar_url($new_members[userid]);
        if (!
$new_members[avatarurl]) {
            
$new_members[avatarurl] = $stylevar['imgdir_misc'] . '/noavatar.gif';
        } else {
            
$new_members[avatarurl] = $vbulletin->options['bburl'] . '/' $new_members[avatarurl][0];
        }
    }

eval(
'$newest_members .= "' fetch_template('newest_members') . '";');

There's also a weird, "Resource id #21" that is being displayed now above the user..

Any ideas??

Thanks, Marco
Attached Images
File Type: gif nme.gif (5.7 KB, 0 views)
Reply With Quote
  #4  
Old 03-03-2006, 06:37 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are using the same variable name $newest_members for both the SQL-resource and the variable to hold you template output.
Reply With Quote
  #5  
Old 03-03-2006, 02:58 PM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That did it.. haha.. man, PHP is a tricky thing..

Thanks a lot Marco!
Reply With Quote
  #6  
Old 03-05-2006, 09:24 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nahh PHP is straight forward, the tricky thing is the coder
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 08:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05711 seconds
  • Memory Usage 2,243KB
  • Queries Executed 14 (?)
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
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (1)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete