Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Display results based on dropdown selected dropdown value

Display results based on dropdown selected dropdown value

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
databasephpsql-serversysadminhelp
3 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samflex
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • S samflex

      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

      T Offline
      T Offline
      tobisoft
      wrote on last edited by
      #2

      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.

      N 1 Reply Last reply
      0
      • T tobisoft

        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.

        N Offline
        N Offline
        nilprajapati
        wrote on last edited by
        #3

        hello

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups