Hello John,
Tuesday, August 10, 2004, 12:35:30 AM, you wrote:
JWH> From: "adwinwijaya" <[EMAIL PROTECTED]>
>> Assume I have array that looks like :
>>
>> Array(
>> 'type'->'Fiction',
>> 'notes'->'Fiction books from a-z',
>> 'list'-> Array(
>> 'list'-> [0]->array(
>> 'title'->'xzy',
>> 'id'->'1')
>> [1]->array(
>> 'title'->'abcd',
>> 'id'->'2')
>> )
>> )
>>
>> Now, I want to display it using smarty os it looks like
>>
>> ---------------------------------------------------
>> Books Result:
>> ----------------------------------------------------
>> 1. Type: Fiction
>> Notes: bla bla bla bla
>> ----------------------
>> ID | Title
>> ----------------------
>> 1 | xzy
>> 2 | abcd
>> ----------------------
>> 2. Type: Non-Fiction
>> Notes: bla bla bla bla
>> ----------------------
>> ID | Title
>> ----------------------
>> 3 | ABCDEFEGH
>> 4 | LALALALLA
>> ----------------------
>> can I do like that with smarty ? and how to do that ?
>> I knew to use array, but for this array, I dont know how to do that
JWH> You need to come up with a better way to format that array based on how you
JWH> want to display it. You can then use {foreach}
JWH> http://smarty.php.net/manual/en/language.function.foreach.php
JWH> ---John Holmes...
yeah, I know it already,
I also tried it using section but I dont know how to translate this
code in php into smarty.
<?php
foreach($Books as $key=>$item)
{
if($key != 'List')
echo $key.' = '.$item ;
else
foreach($Books['List'] as $key2=>$item2)
echo $key2.' = '.$item2 ;
}
?>
I tried like this :
{foreach name=main key=key item=books from=$Books}
{if $books.type != ''}
<table border="1">
<tr>
<td colspan="3">{$books.type} - {$books.wd_type}</td>
</tr>
<tr>
<td>No</td>
<td>Name</td>
<td>Action</td>
</tr>
{foreach name=inner key=key2 item=listbook from=$books.List}
<tr>
<td> {$listbook.id}- {$listbook.name} </td>
</tr>
{/foreach}
</table>
{/if}
{/foreach}
--
Best regards,
adwin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php