function xuesheng(){
$c=M('case')->field('id')->where("upid=5 and state=1")->findAll();
foreach($c as $k => $v){
$caseid[]=$v['id'];
}
$wherecase=" and cid in (".implode(',',$caseid).")";
$qu=M('news')->field('pic1')->where('state=1'.$wherecase)->group('pic1')->order('order
asc ,id desc')->findAll();
$this->assign('qu',$qu);
if($_POST){
$list=M('news')->where("state=1 and pic1='$_POST[pic1]' and pic='$_POST[pic]' and title='$_POST[title]'".$wherecase)->order('order
asc ,id desc')->findAll();
if($list){
foreach($list as $k => &$v){
$case=M('case')->field('name')->where("id=$v[cid]")->find();
$v['case_name']=$case['name'];
}
}
$this->assign('list',$list);
}
$this->display('xuesheng');
}
如何加一句,如果没有找到相关信息,就提示 对不起,您没有被录取。
function xuesheng(){
$c=M('case')->field('id')->where("upid=5 and state=1")->findAll();
foreach($c as $k => $v){
$caseid[]=$v['id'];
}
$wherecase=" and cid in (".implode(',',$caseid).")";
$qu=M('news')->field('pic1')->where('state=1'.$wherecase)->group('pic1')->order('order asc ,id desc')->findAll();
$this->assign('qu',$qu);
if($_POST){
$list=M('news')->where("state=1 and pic1='$_POST[pic1]' and pic='$_POST[pic]' and title='$_POST[title]'".$wherecase)->order('order asc ,id desc')->findAll();
if($list){
foreach($list as $k => &$v){
$case=M('case')->field('name')->where("id=$v[cid]")->find();
$v['case_name']=$case['name'];
}
}else{
$this->assign('message', '对不起,您没有被录取。');
}
$this->assign('list',$list);
}
$this->display('xuesheng');
}
然後模板那裏要判斷
{if $message!=''}
{$message}
{else}
這裏寫之前list的代碼
{/if}
{if $message!=''}
{$message}
{else}
這裏寫之前list的代碼
{/if}
怎么写法,求大神详细~~~
姓名: | |
地区: | |
性别: | |
考号: |
这是模板里的内容
[[ <!--{foreach $list $k => $v}-->
姓名: | |
地区: | |
性别: | |
考号: | |
年级: | |
学期: |
<!--{/foreach}-->]]
在模板里面做个判断 有了就循环显示,没有的话显示提示信息