尝试在html表格中打印数据库中的数据,但它没有正确打印

时间:2017-04-27 08:07:50

标签: php html mysql

我在PHP服务器上使用一个简单的网站来打印表格中的一系列数据,但当我打开它时,打印 {$ row ['tempLog']} <而不是打印数据/ strong>等问题出在哪里:\

connect.php

<?php

function Connection(){


    $connection = new mysqli("localhost", "root", "EasyMon", "test");

    if ($connection->connect_errno) 
    {
        echo "Failed to connect to MySQL: (" . $connection->connect_errno . ") " . $connection->connect_error;
    }
    echo $connection->host_info . "\n";

    return $connection;
    }
?>

这里是index.php网站:

    <?php

    include("connect.php");     

    $link=Connection();

    $result=mysqli_query($link,"SELECT * FROM `Tabella1` ORDER BY `tempLog`");

?>
<html>
    <head>
        <title>Dati</title>
    </head>
    <body>
        <h1>Potenziometro e sensore</h1>

        <table border="1" cellspacing="1" cellpadding="1">
        <tr>
            <td>&nbsp;Timestamp&nbsp;</td>
            <td>&nbsp;Temperature&nbsp;</td>
            <td>&nbsp;Moisture&nbsp;</td>
        </tr>
        <?php
            if($result!==FALSE){
                while($row = mysqli_fetch_array($result)) { 
                    echo ("<tr><td>{$row['tempLog']}</td><td>{$row['potenza']}</td><td>{$row['sensore']}</td></tr>");
                }
                mysqli_free_result($result);
                mysqli_close($link);
            }
        ?>
        </table>
    </body>
</html>         

0 个答案:

没有答案