How to use a value from a drop-down as a filter in a SELECT query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StarLavender
    New Member
    • Apr 2010
    • 33

    How to use a value from a drop-down as a filter in a SELECT query?

    Hi. I want to have a query as below.

    Code:
    $sql = "SELECT amount FROM payment WHERE id = '$a'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    $amount = $row['amount'];
    The value for $a variable is getting from the selection on drop down list. For example, the user select id=11, then the amount for this id is 10 which select from database. So how am I going to assign the value to $a based on the drop down selection of the user? Thanks in advance for any help.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    The value is written in the HTML like
    Code:
    <option name="samename" value="10">Choice
    Then in php
    Code:
    $a = $_POST['samename'];

    Comment

    Working...