Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Loop Question

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
insectis
Smarty n00b


Joined: 27 Aug 2003
Posts: 4

PostPosted: Wed Aug 27, 2003 10:48 pm    Post subject: Loop Question Reply with quote

Hey all,

I just started using Smarty, so this will most likely be a stupid question. Wink

My problem is: I'm grabbing info from a database, putting it into a variable and then using that variable in the TPL file. According to the debugging info, I'm populating the variables correctly; I can't, however, get the variables to print anything when calling them from the TPL.

Here's my code:

[php:1:8bf470e22c]<?php
for ($i = 1; $i < $newsNumRows + 1; $i++) {
$newsRow = mysql_fetch_array($newsResult);

$smarty->assign("newsDate[$i]", $newsRow['date']);
$smarty->assign("newsTitle[$i]", $newsRow['title']);
$smarty->assign("newsSource[$i]", $newsRow['source']);
}
?>[/php:1:8bf470e22c]


Code:

{section name=news loop=$newsTitle}
   {strip}
     <table width="430" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="15" valign="top"><img src="../images/bullet_wtrdrop1.gif" width="15" height="12"></td>
          <td width="100%"><span class="Utxt1"><b>{$newsDate[news]}</b></span><br>
            <a href="article_062203.htm">{$newsTitle[news]}</a>., <i>{$newsSource[news]}</i></td>
        </tr>
      </table>
     <table width="430" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="30"><img src="../images/divline_1.gif" width="430" height="7"></td>
        </tr>
      </table>
      {/strip}
      {/section}


Any help would be greatly appreciated![/code]
?>[/php]
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Aug 28, 2003 1:08 am    Post subject: Reply with quote

Hi insectis--I think that this thread will be helpful. If not, shout out and I'll try to do better for ya Smile
Back to top
View user's profile Send private message
insectis
Smarty n00b


Joined: 27 Aug 2003
Posts: 4

PostPosted: Thu Aug 28, 2003 4:48 pm    Post subject: Reply with quote

Perfect! Thanks a lot!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP