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 06-02-2008, 10:29 PM
The-Ensemble's Avatar
The-Ensemble The-Ensemble is offline
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Columnizing

I've NO idea what I am doing wrong here.

PHP Code:
$counter 0;

$result mysql_query("query");

while (
$category mysql_fetch_assoc($result)) {

$columncount '3';
$counter++;

$categoryname $category['catname'];
$catid $category['catid'];
$catdesc $category['catdesc'];

eval(
'$cats .= "' fetch_template('template') . '";');

if (
$counter == $columncount)
{
echo 
'</tr><tr>';
$counter 0;
}


It resets the counter to zero yet won't print </tr><tr> I've tried dump it with
PHP Code:
?> <?php
tags and that did nothing, I don't get what I've done wrong for it to not work. In theory it should all be working fine, but its not.

NOTE: I cut out the template name and query because they aren't really relevant they both work perfectly and this is a snippet of the overal code the rest of it isn't relevant to this part (or even executed yet) hence why I haven't posted it.
Reply With Quote
  #2  
Old 06-02-2008, 10:40 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is a closing curly brace (}) missing from your while() statement. Also you don't need the single quotes around the 3 in [minicode]$columncount = '3';[/minicode]. Run
PHP Code:
var_dump($cats); 
and throw in an echo statement into your while and see if you get any output. Also run var_dump() on $counter to see if it is changing.

Maybe check that you are getting results from the database first.
Reply With Quote
  #3  
Old 06-02-2008, 10:45 PM
The-Ensemble's Avatar
The-Ensemble The-Ensemble is offline
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The query is working fine, its returning all 4 records from the database with errors and the counter is working fine as I've put $counter in the template and its clearly stating 1-3 then resets to 1 without adding the </tr><tr> on 3.

See attached picture. Its returning the names, the descriptions and the counter.
Attached Images
File Type: jpg CATS.jpg (13.4 KB, 0 views)
Reply With Quote
  #4  
Old 06-02-2008, 11:13 PM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well if you are using templates you can't echo or print anything but what you can do is something like this.
PHP Code:
$counter 0;

$result mysql_query("query");

while (
$category mysql_fetch_assoc($result)) {

$columncount 3;
$counter++;

$categoryname $category['catname'];
$catid $category['catid'];
$catdesc $category['catdesc'];

eval(
'$cats .= "' fetch_template('template') . '";');

if (
$counter == $columncount)
{
$cats .= '</tr><tr>';
$counter 0;
}


Reply With Quote
  #5  
Old 06-02-2008, 11:28 PM
The-Ensemble's Avatar
The-Ensemble The-Ensemble is offline
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh wow, that works. Thanks!

Question: what does the . in .= do?
Reply With Quote
  #6  
Old 06-03-2008, 04:17 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Concatenate

Google it.
Reply With Quote
  #7  
Old 06-03-2008, 09:25 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Always check the HTML source of the output when you're using PHP and things do go to plan. Sometimes the browser hides incorrectly placed code so you don't always see the exact output. It probably would have shown you your error.
Reply With Quote
  #8  
Old 06-03-2008, 12:56 PM
The-Ensemble's Avatar
The-Ensemble The-Ensemble is offline
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
Always check the HTML source of the output when you're using PHP and things do go to plan. Sometimes the browser hides incorrectly placed code so you don't always see the exact output. It probably would have shown you your error.
It didn't output the </tr><tr> at all I put <!-- cat --> at the top and <!-- / cat --> at the bottom of the template to check if it was being outputted but in the wrong place. And It wasn't. But its working nicely now so thats all that matters. :up:
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:13 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.04006 seconds
  • Memory Usage 2,266KB
  • 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
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (1)postbit_attachment
  • (8)postbit_onlinestatus
  • (8)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