更改

时间:2017-04-22 16:38:54

标签: php

我想将Drop Down值传递给php,我是PHP新手请帮助

<html>
<head>
 <script>

    function displayVals() {
      var singleValues = $("#account").val();

      $("p").html("<b>Single:</b> " + singleValues);
    }
</script>
 <select id="account" name="account">
    <option value="1">Tes1</option>
    <option value="2">Tes2</option>
  </select>

</head>
<body>

<?php

$account = $_get['account']; 

echo $account;  

?>

</body>
</html>

嗨,我想将Drop Down值传递给php,我是PHP的新手请帮忙

2 个答案:

答案 0 :(得分:0)

<?php

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

    echo $_POST['account'];
}

?>

<form action="" method="POST">
    <select id="account" name="account">
        <option value="1">Tes1</option>
        <option value="2">Tes2</option>
    </select>
    <input type="submit" name="submit"/>
</form>

您需要制作表格

答案 1 :(得分:0)

以下是您的解决方案,

<?php
    if (isset($_REQUEST['save'])) {
        $sql = "SELECT Business_Unit, COUNT(Joining_Month) AS 'A' FROM jl WHERE Business_Unit = '".$_REQUEST['opt']."' GROUP BY Business_Unit";

        // Here is your sql query
        echo $sql;exit();
    }
?>

您的HTML代码:

<form method="post" action="">
    <select name="opt">
        <option value="1">Option 1</option>
        <option value="2">Option 2</option>
        <option value="3">Option 3</option>
        <option value="4">Option 4</option>
    </select>

    <input type="submit" name="save" />
</form>

给出简单的工作演示以满足您的要求。希望它会对你有所帮助。