Réf. : Re: Réf. : [SMARTY] Section Problem

From: Date: Thu, 16 Jan 2003 16:38:06 +0000
Subject: Réf. : Re: Réf. : [SMARTY] Section Problem
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7232@lists.php.net to get a copy of this message
Could your problem come from the SQL query? Is your query only SELECT *, or do you have other constraints in the query? Because the result seems caused by a bad JOIN on tables... Is the array good before you pass it to the template? Or is it already corrupt? Personnally, I use a really useful function to view all my arrays (for debugging purposes): function view_array($arr, $td=0) { if ($td) { echo '<td>'; } echo '<table>'; foreach ($arr as $key => $elem) { echo '<tr>'; echo '<td>'.$key.'&nbsp;</td>'; if (is_array($elem)) { view_array($elem, 1); } else { echo '<td>'.htmlspecialchars($elem).'&nbsp;</td>'; } echo '</tr>'; } echo '</table>'; if ($td) { echo '</td>'; } } simply call view_array($your_array) to know if it is proper. And tell me if the array is what you want or if it is what is displayed.. Frank Thiel <subthiel@gmx.net> le 16/01/2003 15:03:05 Pour : Philippe MORANGE/EST/DOSI/BANQUE_INDOSUEZ/FR@BANQUE INDOSUEZ cc : smarty-general@lists.php.net (ccc : Philippe MORANGE/EST/DOSI/BANQUE_INDOSUEZ/FR) Objet : Re: Réf. : [SMARTY] Section Problem At 14:49 16.01.2003 +0100, philippe.morange@ca-indosuez.com wrote: Hello Philippe, >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} Thats what i tried before. Here is the output what i get: PID: 1 THEMA: Haarpflege PID: 1 THEMA: Haarpflege PID: 2 THEMA: Körperpflege PID: 1 THEMA: Haarpflege PID: 2 THEMA: Körperpflege PID: 5 THEMA: Haarausfall But thats the wrong output. The ouput has to be: PID: 1 THEMA: Haarpflege PID: 2 THEMA: Körperpflege PID: 5 THEMA: Haarausfall Whats going wrong? THX Frank

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