简体   繁体   English

从MYSQL导出到HTML

[英]Export from MYSQL to HTML

I am new to MYSQL and i am trying to export my database to html, and put the data into specific html tables. 我是MYSQL的新手,我正在尝试将数据库导出到html,并将数据放入特定的html表中。 I have looked around the site, but i cant get my code to work, can someone help me, and tell me if this code looks right ? 我已经浏览了该站点,但是我无法使代码正常工作,有人可以帮助我,并告诉我此代码是否正确吗?

<?php

    $con=mysqli_connect("xxx","xxx","xxx","xxx","xxx");
    // Check connection
    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    $result = mysqli_query($con,"SELECT * FROM xxx");

    while($row = mysqli_fetch_array($result)) 
    {
        <tr>
            <th bgcolor="#3281c6">" . $row["PO_nummer"]. "</th>
            <th bgcolor="#3281c6">" . $row["Varenummer"]. "</th>
            <th bgcolor="#3281c6">" . $row["Produkt_beskrivelse_"]. "</th>
            <th bgcolor="#3281c6">" . $row["Antal"]. "</th>
    }

    mysqli_close($con);
?>

您似乎期望使用关联数组,而不是常规(编号)数组,在这种情况下,请尝试:

while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) { // code }

Try and echo or print the html 尝试回显或打印html

echo "
<th bgcolor="#3281c6">" . $row["PO_nummer"]. "             </th>
<th bgcolor="#3281c6">" . $row["Varenummer"]. "</th>
<th bgcolor="#3281c6">" . $row["Produkt_beskrivelse_"]. "</th>
<th bgcolor="#3281c6">" . $row["Antal"]. "</th>";

And use single quotes here bgcolor='#3281c6' 并在此处使用单引号bgcolor='#3281c6'

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

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