views:

617

answers:

2

Suggest me a better way to do it. I would like to show the array result in the horizontal manner.

Column1 | Column 2 | Column 3
3 | 7 | 10

now it shows in vertical manner as follows

Column1 | Column 2 | Column 3
3
7
10


Array Result : Stored in $result variable and assigned in smarty variable

Array
    (
        [0] => Array
            (
                [1] => 3
                [Value] => 3
            )
        [1] => Array
            (
                [1] => 7
                [Value] => 7
            )
        [2] => Array
            (
                [1] => 10
                [Value] => 10
            )
    )

.tpl code

<div>
    <ul>
       <li>Column1</li>
       <li>Column2</li>
       <li>Column3</li>
       <div class="clear"></div>
    </ul>

    {section name="index" loop=$result}
     <ul>                          
        <li>{$result[index].value}</li>
        <div class="clear"></div>
     </ul>
    {/section}
</div>
A: 

Does this work?

<table>
 <tr>
  <th>Column1</th>
  <th>Column2</th>
  <th>Column3</th>
 </tr>

 <tr>
 {section name="index" loop=$result}
   <td>{$result[index].value}</td>
 {/section}  
 </tr>
</table>
schnaader
+1  A: 

Put the UL out of your loop and make sure that LI's display is set to inline or float left.

<ul>
{section name="index" loop=$result}                     
   <li style="float:left;">{$result[index].value}</li>
{/section}
   <br style="clear:both" />
</ul>
SleepyCod
Thanks Sleepycod. I tried. Yes the li is set to float:left and put the ul outside but same output.
Webrsk
{/section} (here) <-- Move your "<div class="clear"></div>" block here
SleepyCod