<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'
我想问$sqlf="select * from ZZB.people where Ptype='admin' and Pname ='".$t.tname."'";中$t.tname输入的是上面的内容啊
<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());
中的 $t.tname 只能是 tname
因为 $t 未定义只能为 ''
而 tname 是字符串标量