douhuang9886 2009-06-03 12:04
浏览 22
已采纳

使用php和smarty以水平方式显示数组数据

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>
  • 写回答

2条回答 默认 最新

  • duandan5471 2009-06-03 12:10
    关注

    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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效