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 01-28-2004, 10:01 AM
Harlequin's Avatar
Harlequin Harlequin is offline
 
Join Date: Aug 2003
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $template call vs. echo=""; // loop.

I'm beginning to get a little confused by something. Maybe my query needs to be changed for this.

In a nutshell, what is the difference between :

PHP Code:
$cc $DB_site->query(" SELECT * FROM tagio ");

while ( 
$cy $DB_site->fetch_array $cc ) ) :
$taglist "$cy[tags]";
endwhile;

// calling $taglist in the template
eval("dooutput(\"".gettemplate("cc_tag_test")."\");"); 

or

PHP Code:
$cc $DB_site->query(" SELECT * FROM tagio ");

while ( 
$cy $DB_site->fetch_array $cc ) ) :
$taglist ""$cy[tags] ."<br>";
endwhile;

// calling $taglist in the template
eval("dooutput(\"".gettemplate("cc_tag_test")."\");"); 

when compared to:

PHP Code:
$cc $DB_site->query(" SELECT * FROM tagio ");

while ( 
$cy $DB_site->fetch_array $cc ) ) :
echo 
"$cy[tags]";
endwhile; 
??


The problem is $taglist=""; in the template isn't calling the loop -- only the first result of the loop, while echo=""; calls everything in the loop fine and as it should.

I need the looped results to display in the template using $taglist - but apparently I'm doing something wrong here.

PS. Moved and erased this from another thread - was off-topic to that particular thread.
Reply With Quote
  #2  
Old 01-28-2004, 10:44 AM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$cc $DB_site->query("SELECT * FROM tagio"); 

while(
$cy $DB_site->fetch_array($cc)) {
    
$taglist .= $cy['tags'] .'<br />'
}

// calling $taglist in the template 
eval("dooutput(\"".gettemplate("cc_tag_test")."\");"); 
Note that its $taglist .= .... the . appends the content onto the end of the variable while just = overwrites it each time meaning that $taglist at the end only contains the last result from the query.
Reply With Quote
  #3  
Old 01-28-2004, 10:51 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use this to output via templates

PHP Code:
$pass '1';
while (
$query_array $DB_site->fetch_array($var))
{
    if (
$pass '1')
    {
        eval(
"\$output = \"".gettemplate('template')."\";");
    }
    else
    {
        eval(
"\$output .= \"<br /> ".gettemplate('template')."\";");
    }
    
$pass++;

Reply With Quote
  #4  
Old 01-28-2004, 11:00 AM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
.= 
Concatenation

Pretty much the reason was like NTLDR had stated, the concatenation is what adds the new info to the variable each time the loop passes. Once you add the concatenation to the variable there'll be no difference btw the three examples in general. Just using the variable allows placement in the template whether then echo'ing data before the tempate is output.

Cheers,
g-force2k2
Reply With Quote
  #5  
Old 01-28-2004, 04:27 PM
Harlequin's Avatar
Harlequin Harlequin is offline
 
Join Date: Aug 2003
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You guys are wonderful.

Thank you all!
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:11 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.07218 seconds
  • Memory Usage 2,215KB
  • 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
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete