PDA

View Full Version : Calling a template in a while


The-Ensemble
06-01-2008, 01:11 AM
I'd of written a more descriptive title if I knew what was wrong.

I'm trying to list information from a table and to do it I first printed a template then underneath that in the plugin I wrote.

while ($category = mysql_fetch_assoc($result)) {

$categoryname = $category['name'];
$catid = $category['id'];
$catdesc = $category['description'];

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

}

And it returns blank, I know its not the database or the while thats the problem, because before I did it echo'ing the html and the variables and it worked fine.

I added eval for the template, and put $cats in the first printed template for where I wanted these results to go and they don't show up and I don't get why. Its probably something stupid I'm overlooking.

Any ideas?

EDIT--Oh and I know its not the template name, I've checked that around 4 times now.

mikesz
06-01-2008, 01:20 AM
Where is your query?

The-Ensemble
06-01-2008, 01:29 AM
Its above.

Heres the whole plugin

if ($_REQUEST['do'] == 'catlist')
{
$result = mysql_query("SELECT * FROM `vb_extra_cats` ORDER BY `displayorder`;");

eval('print_output("' . fetch_template('extra_categories') . '");');

while ($category = mysql_fetch_assoc($result)) {

$categoryname = $category["name"];
$catid = $category['id'];
$catdesc = $category['description'];

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

}


}

MoT3rror
06-01-2008, 03:00 AM
How are you outputting $cats? echo? Using it in a template that is further down the code using print_output function? Your current code is outputting nothing.

The-Ensemble
06-01-2008, 04:45 AM
I'm outputting it through the extra_categories template using $cats to compile the list.

MoT3rror
06-01-2008, 05:46 AM
Try moving this after the while

eval('print_output("' . fetch_template('extra_categories') . '");');

The-Ensemble
06-01-2008, 06:25 AM
Try moving this after the while

eval('print_output("' . fetch_template('extra_categories') . '");');

Hey that worked, thanks!

Opserty
06-01-2008, 08:55 AM
print_output() end the script execution, hence nothing after that line will be run. :)