1 <form action="__URL__/lists" method="POST"> 2 <input type="hidden" name="flag" value="search"> 3 标题:<input type="text" name="title" value="" class="queryInput"> 4 文章分类:<select name="cate" class="querySelect"> 5 <option value="">请选择...</option> 6 <volist name="alist" id="vo"> 7 <option value="{$vo.id}"> 8 <?php 9 for($i=0;$i<$vo['count']*3;$i++){ 10 echo " "; 11 } 12 ?> 13 {$vo.cname}{$vo.id}</option> 14 </volist> 15 </select> 16 <input type="submit" value="查询" class="formbtn"> 17 </form>
1 if($_POST['title']!=""){ 2 $Article = D("Article"); 3 $title = trim($_POST['title']); 4 $lists = $Article->where("title='$title'")->select(); 5 $this->assign('lists',$lists); 6 $this->display(); 7 }elseif($_POST['cate']!=""){ 8 $Article = D("Article"); 9 $cid = $_POST['cate']; 10 echo $cid; 11 $lists = $Article->where("cid=$cid")->select(); 12 $this->assign('lists',$lists); 13 $this->display(); 14 }else{ 15 。。。 16 }
用表单中的title和cate两个name分别是否为空来判断是提交的哪个单一表单。