如何修复HTML表单中未显示的回显消息

时间:2019-04-10 02:47:34

标签: php html

我几乎完成了我的程序,这是一个简单的状态发布系统。如果用户输入的状态不在数据库内部,则尝试回显错误消息很困难。

我见过MySQLi If condition alert msg not showing the outputECHO not showing in HTML from PHP,但它们都不能解决我的问题。

我已经尝试将echo语句在超链接之后移至,以查看是否可以解决该问题,但事实并非如此。我也尝试过在工作的else块中添加echo语句。

        //Query's used to check if their is data in the 'status' table and if the table 'status' exists
        $query = "select * from status where status like '$status%'";
        $check_query = "DESC status";   

        $result = mysqli_query($conn, $check_query);

        // checks if the execution was successful
        if(!$result) {
            //Links to return home if the query's fail.
            echo '<br>';
            echo '<p>Status does not exist in the database</p>';
            echo '<a href="http://mwx9073.cmslamp14.aut.ac.nz/assign1/index.html">Click here to return home</a>';
            echo '<br>';
            echo '<a href="http://mwx9073.cmslamp14.aut.ac.nz/assign1/searchstatuform.html">Click here to search again</a>';
        } else {
            //Displaying the status information if the operation is a success
            $result = mysqli_query($conn, $query);
            while ($row = mysqli_fetch_assoc($result)){
                echo "<br> Status: ".$row["status"].
                    "<br> Status Code: ".$row["code"].
                    "<br> Share: ".$row["share"].
                    "<br> Date Posted: ".$row["post_date"].
                    "<br> Permission: ".$row["permission"];
                echo '<br>';

            }
            echo '<br>';
            echo '<br>';
            echo '<a href="http://mwx9073.cmslamp14.aut.ac.nz/assign1/index.html">Click here to return home</a>';
            echo '<br>';
            echo '<a href="http://mwx9073.cmslamp14.aut.ac.nz/assign1/searchstatusform.html">Click here to search again</a>';
            // Frees up the memory, after using the result pointer
            mysqli_free_result($result);
        }       
        mysqli_close($conn);

我希望echo "<p>Status does not exist in the database</p>";可以打印,但是仅显示超链接,并且前面没有echo语句。

0 个答案:

没有答案