vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Columnizing (https://vborg.vbsupport.ru/showthread.php?t=181324)

The-Ensemble 06-02-2008 10:29 PM

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. :confused:

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.

Opserty 06-02-2008 10:40 PM

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.

The-Ensemble 06-02-2008 10:45 PM

1 Attachment(s)
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.

MoT3rror 06-02-2008 11:13 PM

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;
}




The-Ensemble 06-02-2008 11:28 PM

Oh wow, that works. Thanks!

Question: what does the . in .= do?

Dismounted 06-03-2008 04:17 AM

Concatenate :)

Google it.

Opserty 06-03-2008 09:25 AM

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. ;)

The-Ensemble 06-03-2008 12:56 PM

Quote:

Originally Posted by Opserty (Post 1539553)
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:


All times are GMT. The time now is 06:45 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.01505 seconds
  • Memory Usage 1,740KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete