CI 多表單提交通不過

來源:互聯網
上載者:User
大師們幫看看這段哪錯了
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));

就可以了

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));}//分頁參數,路由配合.....

高手高手高高手

感謝xuzuning對我們這些小鳥的協助

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.