On Tuesday 03 August 2004 15:21, Amanda Hemmerich offered up the following 
tid-bit of information :
> Ok, I am starting a new job and learning a new person's code, and trying
> to learn Smarty at the same time.
>
> This question is so basic, but I have no idea where to look for an
> answer.
>
> ANyway, I need to change the code so that, when there are no row returned
> by the database, a message is displayed saying, "There are no events
> scheduled." or what have you.
>
> Now, the way I would have done this before using smarty would be to check
> the number of records, and if there were none, I would display the
> message, otherwise, I would loop through and display the results,
>
> However, I know one of the points of smarty is to keep code out of the
> presentation layer, so I don't want to go into the template and add an if
> statement in there.
>
> Any help directing me to an example or whatever would be helpful.
>
> Here is what is going on right now in the code:
>
> (in the PHP page)
> $events = $db->getAll($sql_events, DB_FETCHMODE_ASSOC);
> $tpl->assign("events",$events);
>
> (in the template page)
> {section name=id loop=$events}
> <tr>
>     <td class="event">
>     <b>{$events[id].type}</b>: <a class="menulink"
> href="{$url_prefix}/community/events/?id={$events[id].id}">{$events[id].d
>ate|date_format:"%B %e, %Y"}, {$events[id].speaker}</a><br />
>         {$events[id].title}
>     </td>
> </tr>
> {/section}
>
> Thanks,
> Amanda

According to this page 
http://smarty.php.net/manual/en/language.function.if.php you should be able 
to do something like.....

{ if is_array ( $events ) }
        do smarty stuff
{ /if }

-- 
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to