Display results based on dropdown selected dropdown value
-
Dear php gurus, This is my second post on this php forum. Not much luck with my first post. First, please bear with me as this code is rather long. I have this dropdown dynamically populated from SQL Server database. The code below is derived from 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>
When a user selects any value, say Bid, we would like to display all records associated with Bid. In this case, it will be two records. The long code below (sorry again), works perfectly in terms of displaying records. However, when I tried to integrate the code that displays records based on dropdown value, I expected to see just those records. Instead, it displays all records. Can you please see what I am doing wrong? First the code that should display records based on dropdown selection, followed by the long code I am trying to integrate it with. Your help and understanding very much appreciated.//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 );
}
}<?php error_reporting(E_ERROR | E_WARNING | E_PARS
-
Dear php gurus, This is my second post on this php forum. Not much luck with my first post. First, please bear with me as this code is rather long. I have this dropdown dynamically populated from SQL Server database. The code below is derived from 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>
When a user selects any value, say Bid, we would like to display all records associated with Bid. In this case, it will be two records. The long code below (sorry again), works perfectly in terms of displaying records. However, when I tried to integrate the code that displays records based on dropdown value, I expected to see just those records. Instead, it displays all records. Can you please see what I am doing wrong? First the code that should display records based on dropdown selection, followed by the long code I am trying to integrate it with. Your help and understanding very much appreciated.//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 );
}
}<?php error_reporting(E_ERROR | E_WARNING | E_PARS
From the select tag, from my own observation, it appears that you have called the wrong tag "name" from the dropdown. Instead of
if($_GET['Solicitations'] == "Bid")
Since the "select name ="SType" ", why not use
if($_GET['Stype'] == "Bid")
. I think that is where the mistakes comes from. Because it is whatever value you select from the dropdown that becomes the value of the Select tag.
-
From the select tag, from my own observation, it appears that you have called the wrong tag "name" from the dropdown. Instead of
if($_GET['Solicitations'] == "Bid")
Since the "select name ="SType" ", why not use
if($_GET['Stype'] == "Bid")
. I think that is where the mistakes comes from. Because it is whatever value you select from the dropdown that becomes the value of the Select tag.
hello