|
| Hi.
Perhaps because you assigned to $results and not $list?
xo boots
--- Gareth Thomas <garetht@adelphia.net> wrote:
> Apologies if this question has already been asked.I am new to Smarty
> and I
> have spent most of the day trying to get this to work. I am reading
> the
> contents of a table and want to display it in a section, but I just
> get the
> message "Array $list has no entries", which I know it does if I use
> print_r
> in the PHP code. I am sure it's a minor stupidity of mine that's
> causing
> this, any help much appreciated:
>
> PHP script:
>
> <?php
>
> include("../adodb/adodb.inc.php");
>
> include('../Smarty/libs/Smarty.class.php');
>
>
>
> // Set template dir
>
> $smarty->template_dir = 'templates';
>
> // Set compile dir
>
> $smarty->compile_dir = 'templates_c';
>
>
>
> // create object
>
> $smarty = new Smarty;
>
>
>
> $db = NewADOConnection('mysql');
>
> $db->Connect("localhost", "root", "", "test");
>
>
>
> $results = $db->GetAll("SELECT Employee_Id, Employee_Name FROM
> employee");
>
>
>
> if ($results === false) die("failed");
>
>
>
> $smarty->assign('result',$results);
>
> $smarty->display('index.tpl');
>
>
>
> ?>
>
>
>
> Template:
>
>
>
>
>
> <br>
>
> <b>Table Of Employees</b>
>
> <br>
>
> {section name="i" loop=$list}
>
> <b>Name: {$list[i].Employee_Name}; Id:
> {$list[i].Employee_Id}</b><br>
>
> {sectionelse}
>
> <b><br>Array $list has no entries</b>
>
> {/section}
|
|