im Smarty newbee. Trying to show some data from Database, but nothing display in browser page. I tried to show the query in php file, all works fine, but i cant display in Smarty. My code here: New.php
<?php
include 'Smarty/libs/Smarty.class.php';
$link = mysqli_connect ('localhost','xxxx','xxxx','xxxx');
$sql = "SELECT * FROM `s_news`";
$result = mysqli_query($link,$sql);
while($row = mysqli_fetch_assoc($result)) {
$data[] = $row; # $data is the array created for use in the Smarty template.
$smarty->assign('data', $data);
$smarty->display('text.tpl');
}
?>
Text.tpl file:
{foreach from=$cat1 item=item}
<table cellpadding="2" cellspacing="0">
<tr>
<td>Username:</td>
</tr>
{foreach from=$data item=item key=key}
<tr>
<td>{$item.date}</td>
<tr>
{/foreach}
</table>
{/foreach}
Thanks!