代码问题不起作用,不确定我的语法是否关闭或缺少任何内容

时间:2019-10-06 16:15:11

标签: php

由于我是PhP的新手,遇到了5个我似乎无法弄清的错误,这非常令人困惑,这是为了做作业,但是我做了很多事情,我只需要弄清楚问题所在就可以评论代码与代码有关

问题被评论

我试图解决语法问题并最终破坏了一切,所以我又回到了原来的状态

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title> Shippee Credit Interest </title>
    </head>
    <body>

        <h2> Credit Interest Monthly Payments </h2>

        <form action="Shippeelab1.php" method="post">

            <!-- Input -->
            Credit:
            <input type="text" value="2157" name="credit">
            Interest Rating:
            <input type="text" value="26.22" name="interest">
            Monthly Payments:
            <input type="text" value="65" name="monthly">

            <!-- Button -->
            <input type="submit" value="Calculate!" name="btnCalc">

        </form>

        <?php

            if (isset ($_POST['btnCalc'])) // 1.Do not Access Superglobal $_POST Array Directly
            {

                $owe = $_POST['credit']; // 2. Do not Access Superglobal $_POST Array Directly
                $interest = $_POST['interest']; //Do not Access Superglobal $_POST Array Directly
                $payment = $_POST['monthly']; //Do not Access Superglobal $_POST Array Directly


                echo "<table align='left' border='3>";
                echo "<th> Months </th>";
                echo "<th> Interest </th>";
                echo "<th> Still Owed </th>";

                //Stored Balance
                $CC = $owe; 

            for ($array = 0; $owe > 0; $i++)
            {

                //Calulation for Interest 
                $paid = $owe * $interest / 100 / 12;

                //Interest Payments
                $bill = $owe + $interestPay; 

                //Balance Remainder
                $remainder = $owe - $payment + $interestPay;


                if($paid > $remainder)
                {
                    $remainder = "";
                }

                echo "<tr>"
                $rowMonth = $array + 1; //3. Syntax error  variable'$rowMonth'
                $rowInterest = '$' .number_format((float)$paid, 2);
                $rowRemainder '$'.number_format((float)$remainder, 2);//4. possible syntax error string '$'

                echo "<td> $rowMonth </td>";
                echo "<td> $rowInterest </td>";
                echo "<td> $rowRemainder </td>";

                echo "</tr>";

                $owe = $balance;
                }
            echo "</table>";

            $total = $CC + $bill;
            echo "<br>", "You paid over " .rowMonth, " months equals out to $".number_format((float)$total, 2);

            }

            else
            {

                echo "";

            }



        ?>
    </body>
</html>

这只是不编译,而这正是我真正需要做的,我仍然认为我的语法和问题只是错误的地方。任何帮助表示赞赏。

编辑 我的if语句将运行,但是我得到的错误最终是 This is after changing the code but leaving is set as ($_POST["btnCalc"]))

1 个答案:

答案 0 :(得分:0)

1和2应该为$ _Post [“”](双引号)。 3你想念一个;回声之后。 4 $ rowRemainder未设置为等于任何值。