下拉PHP列表 - 如果选择了某些东西会增加价值

时间:2017-04-27 16:35:58

标签: php html5 drop-down-menu

我有这个代码来制作下拉列表:

  <?php

        error_reporting(E_ALL);
        ini_set('display_errors', 1);

        $host = ""; 
        $user = "";
        $pwd = "";
        $db = "";

        /* connect to DBd */
        $mysqli = mysqli_connect("$host", "$user", "$pwd", "$db");

        if (mysqli_connect_errno()) { echo "Error connecting to DB : " . mysqli_connect_error($mysqli); }

        $query = " SELECT `name` FROM `monitoare` ";
        $stmt = $mysqli->prepare($query);

        $stmt->execute();
        $stmt->bind_result($name);
        $stmt->store_result();

        if ($stmt->num_rows > 0) { /* we have results */
            echo"<select name=\"names\"><option value=\"\">Selecteaza monitorul</option>";

            while($stmt->fetch()){
                echo "<option value=\"$name\">$name</option>";
            }

            echo"</select>";
        }
        else
        { echo"[ no data ]"; }
        ?>

我想做一个计算器来计算数据库中这些名称的值的总和。我想用所选的那些来做总和。我有两个这样的下拉列表

0 个答案:

没有答案