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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-11-2011, 10:28 AM
Twilkey's Avatar
Twilkey Twilkey is offline
 
Join Date: Oct 2006
Posts: 314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Query ends after 1 loop

What about this code could cause only one row to be displayed?

I have tried this with $blogs = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "blog");
and there are over 1000 entries to display, so I am pretty sure the query is fine. I tried deleting the avatar code just to see if it helped, but when I go to save the plugin, I get a 301 error. So i can not even get rid of that code to test.

PHP Code:
$blogs $db->query_read("SELECT * FROM " TABLE_PREFIX "blog WHERE `state` = 3 ORDER BY dateline DESC LIMIT 0, 3");  
   
  while (
$blog $db->fetch_array($blogs))  
  { 
    
$blog[blogid] = $blog['blogid'];  
    
$blog[title] = substr($blog['title'], 030) . '...'
    
$blog[comments] = $blog['comments_visible'];  
    
$blog[userid] = $blog['userid'];  
    
$blog[username] = $blog['username']; 
    
$blogdate vbdate($vbulletin->options['dateformat'], $blog['dateline'], true); 

               
//Avatar Display 
               
$avatarurl1 fetch_avatar_url($blog[userid]); 
                       if (
$vbulletin->options['usefileavatar']) 
                       {                            
                           if (
$avatarurl1
                           { 
                                 
$avatarurl $vbulletin->options['bburl'] . '/' $vbulletin->options['avatarurl'] . '/avatar' $blog[userid] . '_' $blog[userid] . '.gif'
                           } 
                           else 
                           { 
                                 
$avatarurl $vbulletin->options['bburl'] . "/review/images/noavatar.gif"
                           }     
                       } 
                       else 
                       { 
                           if (
$avatarurl1
                           { 
                                 
$avatarurl $vbulletin->options['bburl'] . '/image.php?u=' $blog[userid]; 
                           } 
                           else 
                           { 
                                 
$avatarurl $vbulletin->options['bburl'] . "/review/images/noavatar.gif"
                           }                             
                       } 
        
$blog_bits vB_Template::create('news_blog_bit'); 
        
$blog_bits->register('blogid'$blog[blogid]); 
        
$blog_bits->register('blogtitle'$blog[title]); 
        
$blog_bits->register('blogcomments'$blog[comments]); 
        
$blog_bits->register('bloguserid'$blog[userid]); 
        
$blog_bits->register('blogusername'$blog[username]); 
        
$blog_bits->register('blogdate'$blogdate); 
        
$blog_bits->register('avatarurl'$avatarurl); 
        
$blog_bits .= $blog_bits->render();    
  } 
HTML Code:
<li class="forumbit_nopost L2" id="catblogs">
    <div class="forumrow L2">
                    <a href="blog.php?b={vb:raw blogid}" target="_blank"><img src="review_sidebarimage.php?image={vb:raw avatarurl}" class="forumicon" border="0" /></a>
        <div class="forumdata">
<div class="datacontainer">
            <h2 class="forumtitle"><a href="blog.php?b={vb:raw blogid}" class="forumtitle">{vb:raw blogtitle}</a></h2>
            <p class="tcatDesc">
            Posted By: {vb:raw blogusername}<br />
            Posted On: {vb:raw blogdate}<br />
            Comments: {vb:raw blogcomments}</p>
        </div>
</div>
    </div>

</li>
Reply With Quote
  #2  
Old 03-11-2011, 11:32 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

LIMIT 0, 3 is only going to give you the first 3 results from the database. And the end } should be after the while loop (before //Avatar Display), shouldn't it?
Reply With Quote
  #3  
Old 03-11-2011, 12:01 PM
Twilkey's Avatar
Twilkey Twilkey is offline
 
Join Date: Oct 2006
Posts: 314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

3 results is what I wanted, and as for the last }. Doing that would just cause the whole thing to stop working.

Either way, I figured out the problem. I used $blog_bits to create the template and register the variables, then I also used the same to store the render of the template. You can not do that. So I simply made
PHP Code:
$blog_bits .= $blog_bits->render();
into 
$blog_bit 
.= $blog_bits->render(); 
It was a simple mistake on my part.

Thanks for your input though Boofo.
Reply With Quote
  #4  
Old 03-11-2011, 12:21 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad you got it. I still don't see why you need the Avatar Display and the template render in the while loop. But that doesn't matter now that you have it working.
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 11:39 AM.


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.03764 seconds
  • Memory Usage 2,226KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete