Réf. : [SMARTY] Section Problem

From: Date: Thu, 16 Jan 2003 13:49:49 +0000
Subject: Réf. : [SMARTY] Section Problem
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7223@lists.php.net to get a copy of this message
Hi, well first of all you should have $smartytemp->display("cat_closed2.tpl"); instead of $smartytemp->display("cat_closed2.php"); But maybe Smarty doesn't care if the extension is tpl or php, I don't know... Ok so let's talk about your problem. Why don't you do it like this: while ($Row = $Result->fetchRow()){ $pid[] = $Row[0]; $Thema[] = $Row[1]; } $smartytemp->assign("pid", $pid); $smartytemp->assign("Thema", $Thema); $smartytemp->display("cat_closed2.tpl"); or even better (imho): while ($Row = $Result->fetchRow()){ $result[] = array( 'pid' => $Row[0], 'thema' => $Row[1] ); } $smartytemp->assign("result", $result); $smartytemp->display("cat_closed2.tpl"); And change your {section} to be good: {section name=schuu loop=$result} PID: {$result[schuu].pid}&nbsp;&nbsp;&nbsp; THEMA: {$result[schuu].thema}<br> {sectionelse} There are no values to loop through. {/section} Try that and tell me if it works. "Frank Thiel" <subthiel@gmx.net> le 16/01/2003 13:39:54 Pour : smarty-general@lists.php.net cc : (ccc : Philippe MORANGE/EST/DOSI/BANQUE_INDOSUEZ/FR) Objet : [SMARTY] Section Problem I do have a strange problem with sections. This is my database: Table faqcategory pid Thema 1 Haarpflege 2 Körperpflege 5 Haarausfall This is my database connection with Pear: $query = "SELECT * FROM faqcategory"; $Result = $db->query($query); while ($Row = $Result->fetchRow()){ $smartytemp->assign("pid", $Row[0]); $smartytemp->assign("Thema", $Row[1]); $smartytemp->display("cat_closed2.php"); } That is the cat_closed2.php {section name=schuu loop=$pid} PID: {$pid[schuu]}&nbsp;&nbsp;&nbsp; THEMA: {$Thema[schuu]}<br> {sectionelse} There are no values to loop through. {/section} Now i do´nt get the output waht i want. Here is my output: PID: 1 THEMA: H PID: 2 THEMA: K PID: THEMA: ö PID: 5 THEMA: H PID: THEMA: a PID: THEMA: a PID: THEMA: r PID: THEMA: a Without [schuu] it looks like that: PID: 1 THEMA: Haarpflege PID: 2 THEMA: Körperpflege PID: 2 THEMA: Körperpflege PID: 5 THEMA: Haarausfall PID: 5 THEMA: Haarausfall PID: 5 THEMA: Haarausfall PID: 5 THEMA: Haarausfall PID: 5 THEMA: Haarausfall Whats going wrong? Am i doing the wrong way? THX Frank Thiel -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#7223) next »