Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 根据下拉列表中的选定值显示记录_Php - Fatal编程技术网

Php 根据下拉列表中的选定值显示记录

Php 根据下拉列表中的选定值显示记录,php,Php,用户搜索一个名为search.php的页面,搜索结果显示在另一个名为results的页面上 这很有效 以下是相关代码: $fields = array( 'projectTitle' => array('field' => 'b.BidTitle', 'searchType' => 'like'), 'BidType' => array('field' => 'b.BidType', 'searchType' => 'equal')

用户搜索一个名为search.php的页面,搜索结果显示在另一个名为results的页面上

这很有效

以下是相关代码:

  $fields = array(
      'projectTitle' => array('field' => 'b.BidTitle', 'searchType' => 'like'),
      'BidType' => array('field' => 'b.BidType', 'searchType' => 'equal'),
      'BidStatus' => array('field' => 'b.BidStatus', 'searchType' => 'equal'),
      'department' => array('field' => 'b.Department', 'searchType' => 'equal'),
      'bidId' => array('field' => 'b.BidID', 'searchType' => 'equal'),
      'bidDate' => array('field' => 'b.BidDate', 'searchType' => 'equal'),
      'dueDate' => array('field' => 'b.DueDate', 'searchType' => 'equal')

  );

  $where = array();
  foreach($fields as $fieldPost => $field) {
      if(isset($_POST[$fieldPost]) && strlen($_POST[$fieldPost]) > 0) {
          if($field['searchType'] == 'like') {
              $where[] = "".$field['field']." LIKE '%" . ms_escape_string($_POST[$fieldPost]) . "%'";
          } else {
              $where[] = "".$field['field']." = '" . ms_escape_string($_POST[$fieldPost]) . "'";
          }
      }
  }
     $sql = "Select b.ID,convert(char(10),b.BidDate,101) BidDate,convert(char(10),
            b.DueDate,101)DueDate,b.BidTitle,b.DueTime,b.BidID,BidIDFile,
            d.Department,b.BidType,CASE WHEN b.AwardDate ='01/01/1900' Then NULL ELSe convert(char(10),b.AwardDate,101)END AS AwardDate,
            convert(char(10),b.LastUpdate,101) LastUpdate,s.Status
            FROM bids b inner join dept d on b.Department=d.DeptID inner join Status s on b.BidStatus=s.StatusId " . ( count($where) > 0 ? " WHERE " . implode(' AND ', $where) : "" );
  //echo $sql;
    $params = array();
    $options =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
    $query = sqlsrv_query( $conn, $sql , $params, $options );

    $num_rows = sqlsrv_num_rows($query);
现在,我从View-->Source生成了以下下拉值

<select name="SType">
  <option value=""></option>
  <option value="Bid" name="Bid">Bid[2]</option>
  <option value="Lib CM" name="Library CM">Lib CM[23]</option>
  <option value="Quote" name="Quote">Quote[20]</option>
  <option value="RFP" name="RFP">RFP[2]</option>
  <option value="Removed" name="Removed">Removed[29]</option>
  <option value="Archived" name="Archived">Archived[4501]</option>
  <option value="Awarded" name="Awarded">Awarded[40]</option>
  <option value="Open" name="Open">Open[47]</option>
  <option value="Closed" name="Closed">Closed[11]</option>
  <option value="Under Review" name="Under Review">Under Review[126]</option>
  <option value="Cancelled" name="Cancelled">Cancelled[64]</option>
</select>

非常感谢我在这里得到的所有帮助。

$\u请求['requestments']
需要是
$\u请求['SType']
,因为您使用的是
-对于
$\u GET['requestments']
$\u GET['SType']也一样,
不保留名称属性,
保留名称属性。只需使用其中的值即可。@Fred ii-,谢谢。但问题是,它仍然显示来自各种其他征求类型的记录,而不仅仅是您传递给它的记录。在这种情况下,我希望只看到与这两个出价相关的结果,但结果并不理想。
//If value matches dropdown value, then display records associated with dropdown value
if(isset($_REQUEST['Solicitations'])){
    if($_GET['Solicitations'] == "Bid"){
    $result = "SELECT * FROM bids where BidStatus = 1 and BidType = 'Bid' ORDER BY title";
    $query = sqlsrv_query( $conn, $sql , $params, $options );
    }
  }