CI 多表单提交通不过

WBOY
Release: 2016-06-23 13:57:59
Original
806 people have browsed it

大师们帮看看这段哪错了
if (!empty($_POST['num']) ||
!empty($_POST['title']) ||
!empty($_POST['price']) ||
!empty($_POST['years']) ||
!empty($_POST['season']) ||
!empty($_POST['groups'])
{

$w = array(
foreach($_POST as $k=>$v):
  if(!empty($v)){ 
$k => $v;
}
endforeach;
)
}
就是通不过


回复讨论(解决方案)

这是什么写法,数组里面foreach ? 能行吗? 

这写法闻所未闻啊

我就是想做一个多表单搜索,
就是给搜索同时限制多个条件,每个条件各用一个表单的形式,
有单行文本框,也有下拉菜单,可以不同时限制全部条件,
这个不知道怎么做

为什么要多表单,一个表单里,多个搜索条件不行吗???

不就是过滤掉无效(空值)的传入项吗?

$w = array_diff($_POST, array('', 0));
Copy after login

就可以了

xuzuning !
你就是我的大神,崇拜你崇拜的五体投地

if (!empty($_POST['num']) ||
!empty($_POST['names']) ||
!empty($_POST['price']) ||
!empty($_POST['years']) ||
!empty($_POST['season']) ||
!empty($_POST['groups']) ||
!empty($_POST['note']) )
{



$w = array_diff($_POST, array('', 0));}

//分页参数,路由配合
$config['base_url'] = 'http://localhost/ci/index.php/product/search';
$num = $this->product_model->search_page( $w);//这里调用时说$w没定义
$config['total_rows'] = $num;
$config['per_page'] = 80;
$config['uri_segment'] = '3';
$this->pagination->initialize($config);

$pageNum=$this->uri->segment(3,1);
if($pageNum==1){
$offset=0;
}else{
$offset=$config['per_page']*($pageNum-1);
}//分页参数结束

$data['title'] = '商品中心';
// $_where = array('type' => 'newstore');
$data['data'] = $this->product_model->search_paging($w,$config['per_page'],$offset);//这里也说$w没定义

$w = array();if($_POST) {  $w = array_diff($_POST, array('', 0));}//分页参数,路由配合.....
Copy after login

高手高手高高手

感谢xuzuning对我们这些小鸟的帮助

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template