联表查询
field选择要查询的列名,alias为classcourse的别名,join连接两个表
public function list(){
$model = M('classcourse');
$data = $model
->alias('cc')
->field('cc.id,cc.classname,cc.coursename')
->join('__TEACHER__ t on t.id = cc.teacherid')
->where("t.name='XXX'")
->select();
dump($data);
}
验证码
//生成验证码
public function yzm(){
$config=array(
'fontSize' => 45, // 验证码字体大小
'length'=>4,//验证码长度
);
$Verify = new \Think\Verify();
$Verify->entry();
}
将数据在表格中输出,显示编号,并隔行显示样式
.bg{
background: yellow;
}
<volist name="data" id="rows" key='k' mod='2'>
<tr <eq name="k%2" value='1'>class='bg'</eq>>
<td>{$k}</td>
<td><a href='__CONTROLLER__/classs?no={$rows.no}'>{$rows.name|subtext=2}</a></td>
<td>{$rows.sex}</td>
<td>{$rows.tel}</td>
</tr>
</volist>