回应变量结果

时间:2016-09-15 04:37:28

标签: php

我只是从一本书中学习PHP,我正在做一个练习,目的是创建一个成绩计算器。我试图让这个等级在形式下回响,我遇到了麻烦。

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {


        if currentSearch == "new" {
        self.PersonalSearchesList = PersonalSearchesList.sorted{ $0.users < $1.users }

        } else if currentSearch == "top" {

          self.PersonalSearchesList = self.PersonalSearchesList.sorted{ $0.latestUser < $1.latestUser }

        }

2 个答案:

答案 0 :(得分:0)

<html>
<head></head>
<body>

    <form method="post" action="info.php">
        <label>Assignment 1:</label><input type="text" name="assignmentOne" value="0"></br>

        <label>Assignment 2:</label><input type="text" name="assignmentTwo" value="0"></br>

        <label>Assignment 3:</label><input type="text" name="assignmentThree" value="0"></br>

        <label>Assignment 4:</label><input type="text" name="assignmentFour" value="0"></br>

        <label>Assignment 5:</label><input type="text" name="assignmentFive" value="0"></br>

        <label>Assignment 6:</label><input type="text" name="assignmentSix" value="0"></br>

        <label>Final Project:</label><input type="text" name="finalProject" value="0"></br>

        <label>Final Exam:</label><input type="text" name="FinalExam" value="0"></br>

        <input type="submit" name="calculate" value="Calculate Grade"></br>
    </form>

    <?php
    if ($_POST) {

        $assignmentOne = $_POST['assignmentOne'];
        $assignmentTwo = $_POST['assignmentTwo'];
        $assignmentThree = $_POST['assignmentThree'];
        $assignmentFour = $_POST['assignmentFour'];
        $assignmentFive = $_POST['assignmentFive'];
        $assignmentSix = $_POST['assignmentSix'];
        $finalProject = $_POST['finalProject'];
        $finalExam = $_POST['finalExam'];

        $grade = ((($assignmentOne + $assignmentTwo + $assignmentThree + $assignmentFour + $assignmentFive + $assignmentSix) / 6)* 0.50) + ($finalProject * .30) + ($finalExam * .20);
        echo "Final Grade $grade";
    }
    ?>
</div>
</body>
</html>

试试这会有所帮助

答案 1 :(得分:0)

您的表单需要提交按钮和操作属性。你的变量也写得不正确。

<html>
<head></head>
<body>

        <form method="post" action="">
            <label>Assignment 1:</label><input type="text" name="assignmentOne" value="0"></br>

            <label>Assignment 2:</label><input type="text" name="assignmentTwo" value="0"></br>

            <label>Assignment 3:</label><input type="text" name="assignmentThree" value="0"></br>

            <label>Assignment 4:</label><input type="text" name="assignmentFour" value="0"></br>

            <label>Assignment 5:</label><input type="text" name="assignmentFive" value="0"></br>

            <label>Assignment 6:</label><input type="text" name="assignmentSix" value="0"></br>

            <label>Final Project:</label><input type="text" name="finalProject" value="0"></br>

            <label>Final Exam:</label><input type="text" name="finalExam" value="0"></br>

            <input type="submit" name="calculate" value="Calculate Grade"></br>
        </form>

        <?php
            if ($_POST) {
                    $assignmentOne = $_POST['assignmentOne'];
                    $assignmentTwo = $_POST['assignmentTwo'];
                    $assignmentThree = $_POST['assignmentThree'];
                    $assignmentFour = $_POST['assignmentFour'];
                    $assignmentFive = $_POST['assignmentFive'];
                    $assignmentSix = $_POST['assignmentSix'];
                    $finalProject = $_POST['finalProject'];
                    $finalExam = $_POST['finalExam'];

                    $grade = ((($assignmentOne + $assignmentTwo + $assignmentThree + $assignmentFour + $assignmentFive + $assignmentSix) / 6)* .50) + ($finalProject * .30) + ($finalExam * .20);
                echo "Final Grade $grade";

            }   
        ?>
    </div>
</body>