就是循环,和foreach差不多了...测试一下不就知道了

解决方案 »

  1.   

    2.
     循环显示你刚才的那个数组:
     {section name=index loop=$subjects}
        {subjects[index] <br> 
     {/section}
      

  2.   

    打错了不好意思:
     {section name=index loop=$subjects}
    {$subjects[index] <br>
    {/section}
      

  3.   

    第1个
    你在定义数组的时候就定义连接应该可以的吧
    第2个
    发一个比较通俗的给你
    php程序
    $smarty="select * from table";
    $query=mysql_query($sql);
    while($row=mysql_fetch_array($query)){
    $row1[]=array("id"=>$row["dem_id"],"username"=>$row["username"]);
    $smarty->assign("row1",$row1);
    $smarty->assign("username",$row1);
    tpl文件
    {section name=aaa loop=$row1}
           id: {$row1[aaa].id}<br>
           username: {$row1[aaa].username}<br>
    {/section}
      

  4.   

    楼上关于第 1 个问题的答复中如果这样当然是可以
    $smarty->assign("subjects","<a href=test.php?id=$id>".$subjects."</a>");但对于模板端来说,如果他期望的是一个弹出窗口,我就必须修改php文件,而却不能期望修改模板文件得到。我就是希望把这种可能性转移到模板中去。
      

  5.   

    to: mynamesucks(一个晚上梦到你3次zhuying)
    你这几句我没懂啊。而且while在哪里结束?while($row=mysql_fetch_array($query)){
    $row1[]=array("id"=>$row["dem_id"],"username"=>$row["username"]);
    $smarty->assign("row1",$row1);    //两次赋值?
    $smarty->assign("username",$row1);
      

  6.   

    smarty可以用在任何虚礼空间上。
    php:
    $a = array();
    $this->assign('A', $a);smarty:
    {section name="a" loop=A}
    <tr>
      <td>{$A[a]}</td>
    </tr>
    {/section}
    就是这么方便和好用
      

  7.   

    $res = $db->getAll("select newsID,subject,clicked from oa_news");
    $smarty->assign("res",$res);//index.html 啥也没打出来,为什么????????{section name=index loop=$res}
    {$res[index].subject}<br>
    {/section}//$res结果为
    Array
    (
        [0] => Array
            (
                [0] => 5
                [1] => 内部管理系统试用
                [2] => 51
            )    [1] => Array
            (
                [0] => 6
                [1] => 系统新增“企业论坛”模块
                [2] => 19
            )    [2] => Array
            (
                [0] => 7
                [1] => 有了“企业论坛”,请大家把问题反映出来
                [2] => 23
            )    [3] => Array
            (
                [0] => 8
                [1] => 系统新增“我的收藏夹”功能模块
                [2] => 13
            )    [4] => Array
            (
                [0] => 9
                [1] => 劳动纪律管理规定---炎管[2004]4号文
                [2] => 11
            )    [5] => Array
            (
                [0] => 10
                [1] => 系统新增部分功能模块
                [2] => 4
            ))