multidim array
| From: | Wilhelm Kutting | Date: | Mon, 13 Jan 2003 21:51:25 +0000 |
| Subject: | multidim array | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-7155@lists.php.net to get a copy of this message | ||
hi i got problem with a mutlidim array.
ich wnat to get otuput like
ID: 3
Name : Dirk Diggler
Fon1: 05784-248863
Fon2: 025771- 444871
ID: 6
Name: Salma Hayek
Fon1: 14567897
Fon2: 478976131
Fon3: 4569684
Fon4: 5679
The Problem is that i don't know the way how to run thru the 2-dim Fon
Array. Probably someone can help me Out
I tried the Following code (template.html):
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
{section name=nr loop=$results}
<tr>
<td colspan="2"><b>{$results[nr].id}</b></td>
</tr>
<tr>
<td height="5" colspan="2"><img src="/img/1x1.gif"
width="1"
height="1"></td>
</tr>
<tr>
<td height="5" colspan="2">{$results[nr].name}
</td>
</tr>
?
?
?
?
{/section}
</table>
And Called the template from this:
if (isset($sql))$result = mysql_query($sql);
$results = array();
$i=0;
while ($row=mysql_fetch_array($result)) {
$tmp = array(
'id' => $row['id'],
'name' => $row['name'],
'fon',array( 0 =>
$row["fon_1"],
$row["fon_2"],
$row["fon_3"],
$row["fon_4"]
);
$results[$i++] = $tmp;
}
$smarty = new Smarty;
$smarty->assign('results', $results);
$smarty->display('template.html');