Npr. ukoliko imaš
Code:
</php
$smarty = new Smarty;
$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
mysql_select_db(DBNAME, $conn);
$sql = 'SELECT * FROM tabela LIMIT 10';
$results = mysql_query($sql, $conn);
$data = Array();
while($row = mysql_fetch_assoc($results)) {
$data[] = $row;
}
$smarty->assign('data', $data);
$smarty->display('index.tpl');
?>
U template-u bi mogao da koristiš npr
foreach ili
section
Code:
<table>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4</td>
</tr>
{foreach from=$data item="d"}
<tr>
<td>{$d.col1}</td>
<td>{$d.col2}</td>
<td>{$d.col3}</td>
<td>{$d.col4}</td>
</tr>
{foreachelse}
<tr>
<td colspan="4">Data not found!</td>
</tr>
{/foreach}
</table>
<br />
<br />
<br />
<table>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4</td>
</tr>
{section name="d" loop=$data}
<tr>
<td>{$data[d].col1}</td>
<td>{$data[d].col2}</td>
<td>{$data[d].col3}</td>
<td>{$data[d].col4}</td>
</tr>
{sectionelse}
<tr>
<td colspan="4">Data not found!</td>
</tr>
{/section}
</table>
Banned - Not available