欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php加一句如果在数据库里没某条记录,则显示提示消息。判断语句应该怎么改?求大神抱大腿!

程序员文章站 2022-06-01 18:21:33
...
php

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');
}
如何加一句,如果没有找到相关信息,就提示 对不起,您没有被录取。

相关标签: php