|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
deception Smarty Rookie
Joined: 07 Sep 2004 Posts: 7
|
Posted: Tue Sep 07, 2004 6:41 am Post subject: Problem mit foreach Schleife |
|
|
Template:
Code: |
{foreach from=data item=news}
<div id="iframe_news">
<p id="news_headline">{$news.headline}</p><br />
<p id="news_txt">{$news.news}</p><br />
<p id="news_date">Diese News wurde am {$news.date} verfasst.</p><br />
</div>
{/foreach}
|
PHP Code:
Code: |
$sql = "SELECT * FROM news ORDER BY id";
$result = mysql_query($sql);
$smarty_data = array();
while ($data = mysql_fetch_array($result)) {
$smarty_data[] = $data;
}
$smarty->assign('data', $smarty_data);
$smarty->display('main_news.tpl');
|
Kann mir einer Sagen was ich falsch mach? Der schreibt mir in news.headline und news.news und news.date imme nur ein "d" rein!
Mfg Max |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Sep 07, 2004 7:27 am Post subject: |
|
|
es muss "{foreach from=$data item=news}" heissen.
du hast das $ vergessen. |
|
Back to top |
|
deception Smarty Rookie
Joined: 07 Sep 2004 Posts: 7
|
Posted: Tue Sep 07, 2004 7:39 am Post subject: |
|
|
Ach du sch**** ist das Peinlich
*g* |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|