<table id="mytable" cellspacing="0" summary="The technical specifications of the Apple PowerMac G5 series">
<tr> <th>id</th>
    <th>名称1</th>
    <th>名称2</th>
    <th>详情</th>
</tr>
{{foreach item=t from=$tv}}
  <tr>
  <td>{{$t.xz}} </td>
    <td>{{$t.shequ}}</td>
    <td>{{$t.tname}} </td>
    <td>{{php}}
 require "../config/include.php";
$sqlf="select * from ZZB.people where Ptype='admin' and Pname ='".$t.tname."'";
$rsf=mysql_query($sqlf,$conn);
            if(mysql_num_rows($rsf)==0){
                echo '修改'.$sqlf;
            }else{
                echo '查看';
            }
{{/php}} </td>
  </tr>
  {{/foreach}}
</table>$sqlf="select * from ZZB.people where Ptype='admin' and Pname ='".$t.tname."'";
中$t.tname调用的是上面 <td>{{$t.tname}} </td>的$t.tname
结果输出的的是select * from ZZB.people where Ptype='admin' and Pname ='tname'

解决方案 »

  1.   

     $sqlf="select * from ZZB.people where Ptype='admin' and Pname ='".$t.tname."'";这里的$t.tname能这样写的嘛? 你看看你编译的时候,$t.tanme变成什么啦.
      

  2.   

    结果输出的的是select * from ZZB.people where Ptype='admin' and Pname ='tname'
    我想问$sqlf="select * from ZZB.people where Ptype='admin' and Pname ='".$t.tname."'";中$t.tname输入的是上面的内容啊
      

  3.   

    <table id="mytable" cellspacing="0" summary="The technical specifications of the Apple PowerMac G5 series">
    <tr> <th>id</th>
        <th>名称1</th>
        <th>名称2</th>
        <th>详情</th>
    </tr>
    {{$tableContent}}
    </table> //这个当1变量传到HTML {{$tableContent}}
    /*
    foreach item=t from=$tv
      <tr>
      <td>{{$t.xz}} </td>
        <td>{{$t.shequ}}</td>
        <td>{{$t.tname}} </td>
        <td>{{php}}
         require "../config/include.php";
        $sqlf="select * from ZZB.people where Ptype='admin' and Pname ='".$t.tname."'";
    $rsf=mysql_query($sqlf,$conn);
                if(mysql_num_rows($rsf)==0){
                    echo '修改'.$sqlf;
                }else{
                    echo '查看';
                }
        {{/php}}    </td>
      </tr>
      {{/foreach}}
    */$tpl->assign('tableContent',youFunction());
      

  4.   

    php代码段中不能有模板变量,或者说模板变量在php代码段中不起作用$sqlf="select * from ZZB.people where Ptype='admin' and Pname ='".$t.tname."'";
    中的 $t.tname 只能是 tname
    因为 $t 未定义只能为 ''
    而 tname 是字符串标量