gracias GORAK por responder, tienes toda la razon
pero aqui tengo otro problema
Código PHP:
$sql = "SELECT * FROM cars WHERE activ='1' ORDER BY 'date' DESC LIMIT 5";
$result = $db->query($sql);
$num2 = $db->num($result);
if($num2 < 1) {
echo"nada";
}else{
while($row = $db->fetch($result)) {
$car_id = $row['car_id'];
$model = $row['model'];
$template->add_block_vars("car", array(
'CAR_ID' => $car_id,
'MODEL' => $model)
);
}
}
$template->getFile(array(
'index' => 'index.tpl')
);
$template->add_vars(array(
)
);
$template->parse("index");
la funcion add_block_vars
Código PHP:
function add_block_vars($blockname, $vararray)
{
if(strstr($blockname, '.'))
{
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$str = '$this->_tpldata';
for($i = 0; $i < $blockcount; $i++)
{
$str .= '[\'' . $blocks[$i] . '.\']';
eval('$lastiteration = sizeof(' . $str . ') - 1;');
$str .= '[' . $lastiteration . ']';
}
$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;';
eval($str);
}
else
{
$this->_tpldata[$blockname . '.'][] = $vararray;
}
return true;
}
pues aqui no me muestr nada cuando en index.tpl hago esto
Código PHP:
{car.CAR_ID}-{car.MODEL}