[TYPO3] EXT programming question

Jim Sandwick jim at 3ev.com
Mon Oct 16 11:37:05 CEST 2006


Hey,

Its because your overwriting the $content variable every time you loop 
through the foreach statement..

with:		$content = 'asdsf';

rather then: 	$content .= 'sdfsdfsdf';

Use something like:

  foreach ($compr as $key=>$value){
    $content .= '<p>'.$key.':'.$value.'</p>';
  }

Good luck,

Jim Sandwick


Rocky wrote:
> Hey,
> 
> In my EXT, I'm listing the records from an external Database table. 
> Below are the code I'm using.
> 
> /------------------snip begin--------------/
>     foreach ($compr as $key=>$value){
>           $content='
>                          <h5>Hello, World!</h5>
>                          <p>'.$key.':'.$value.'</p>
> ';}
> 
> /------------------snip end---------------/
> 
> It only print out the last array item.
> 
> but with the same DB connection the following codes gives me all the items
> 
> /----------snip begin---------------/
> foreach ($compr as $key=>$value){
>     echo $key."as".$value;   
> }
> /-----------snip end-------------/
> 
> The problem is this is not the typo3 way of out puting the content. Can 
> any of you give a hint on how to show the array items using $content 
> varable in EXT's class file please?
> 
> Thanks in advance!
> Rocky



More information about the TYPO3-english mailing list