繁体   English   中英

PHP代码以HTML显示

[英]PHP Codes are displaying in HTML

我正在使用以下代码从数据库表中获取数据:

<!DOCTYPE HTML>
<html>
    <head>
        <title>Search data</title>
    </head>
    <body>
        <table>
            <tr>
                <td align="center">EMPLOYEES DATA</td>
            </tr>
            <tr>
        <td>
        <table border="1">
            <tr>
            <td>NAME</td>
            <td>EMPLOYEES<br>NUMBER</td>
            <td>ADDRESS</td>
            </tr>
    <?php
        //the example of searching data with the sequence based on the field name
        //search.php
        mysql_connect("localhost","root","");//database connection
        mysql_select_db("db_psu_online");

        $order = "SELECT * FROM tb_income_statement_igp_fields";
        //order to search data
        //declare in the order variable

        $result = mysql_query($order);  
        //order executes the result is saved
        //in the variable of $result

        while($data = mysql_fetch_row($result)){
            echo("<tr><td>$data[1]</td><td>$data[0]</td><td>$data[2]</td></tr>");
        }
    ?>
        </table>
        </td>
        </tr>
        </table>
    </body>
</html>

上面代码的输出是这样的: 在此处输入图片说明

我不知道为什么要打印以下字符: "); } ?>

您是否以扩展名.php保存文件? 您的服务器上是否已安装并启用PHP?

至少有一个答案是“否”,因为您看到的是HTML中原始的PHP输出-如果使用浏览器的“查看源代码”,您会清楚地看到。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM