2014-09-23 91 views
0

此不同勢操作的形式:2提交一個表單基於崗位

<form method="POST" action=""> 
     <input type="text" class="field small-field" name="refone" value="<?php echo Check_Param($refone);?>" /> 
     <input type="submit" class="button" value="search" name="search"/> 
     <input type="submit" class="button" name="print" value="print" /> 
    </form> 

現在,這裏我有兩個作用,

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['search'])) { 

如果搜索按鈕,點擊這個動作只將運行

} else{ 

在未提交表單的情況下,將執行此操作。

} 

現在,這是打印操作將使用if語句,然後導致這樣的事,如果

if(isset($_POST['print'])){ 

這裏的時候,我點擊上方的功能從第一的其他運行打印如果然後它打印結果在這裏將其導出爲PDF作爲搜索按鈕,它只是搜索和結果,但在打印它將打印它,

} 

所以我的問題是我怎麼可以設置打印先去第一,如果將搜索再來找如果(打印)和結果。

這裏我這樣做了,但它不是在這裏工作::

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['search']) || isset($_POST['print'])) { 
/////////////this code runs first 

}

if(isset($_POST['print'])){ 
/////////this runs secound based on resulted rows of first if 
} 

所以我怎麼能管理它

問候

+0

無論如何搜索結果包含什麼?也許你需要堅持任何結果,它可能會返回,然後當按下打印,使用搜索結果 – Ghost 2014-09-23 07:52:42

+0

actully我想在這裏,當我點擊打印它運行兩個如果說明 – SAR 2014-09-23 07:55:00

+0

抱歉的男人,仍然不能理解 – Ghost 2014-09-23 08:06:13

回答

0

您必須包裝他們與(),所以他們會分開評估。

if ($_SERVER['REQUEST_METHOD'] == 'POST' && (isset($_POST['search']) || isset($_POST['print']))) { 

    if(isset($_POST['print'])){ 

     //this runs secound based on resulted rows of first if 

    } 

}