【问题标题】:Export from MYSQL to HTML从 MYSQL 导出到 HTML
【发布时间】:2017-03-08 06:50:34
【问题描述】:

我是 MYSQL 的新手,我正在尝试将我的数据库导出为 html,并将数据放入特定的 html 表中。我环顾了该网站,但我的代码无法正常工作,有人可以帮助我,并告诉我这段代码是否正确吗?

<?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);
?>

【问题讨论】:

  • 有什么问题(异常/不正确的 UI 渲染等),突出显示不会迫使这里的人假设您的问题。
  • 用引号或在 stackoverflow.com/questions/18140270/…

标签: html windows


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    尝试回显或打印 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>";
    

    并在此处使用单引号bgcolor='#3281c6'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      • 1970-01-01
      • 2011-01-05
      • 2021-09-30
      • 1970-01-01
      • 2011-04-23
      相关资源
      最近更新 更多