Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将sql表导入html时获取0结果_Php_Html_Mysqli_Html Table - Fatal编程技术网

Php 将sql表导入html时获取0结果

Php 将sql表导入html时获取0结果,php,html,mysqli,html-table,Php,Html,Mysqli,Html Table,我刚开始使用mysql和php 我试图在表中显示mysql数据库。代码似乎正在运行,但它给出了0个结果。我在mysql表中有2行 <!DOCTYPE html> <html lang="en"> <head> <title>Tronios Exportzendingen</title> <meta charset="utf-8"> <meta name="viewport" content="width=d

我刚开始使用mysql和php

我试图在表中显示mysql数据库。代码似乎正在运行,但它给出了0个结果。我在mysql表中有2行

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Tronios Exportzendingen</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="styles2.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
    <?php
        $servername = "localhost";
        $username = "rubinjo13";
        $dbname = "project1";

        // Create connection
        $conn = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn->connect_error) {
             die("Connection failed: " . $conn->connect_error);
        } 

        $sql = "ExportID, Debiteur, Deb_Name, Tot_Pallets, Tot_Weight, PBS FROM export";
        $result = $conn->query($sql);

        if ($result->num_rows > 0) {
             echo "<table><tr><th>ID</th><th>Debiteur</th><th>Naam</th><th>Aantal Pallets</th><th>Totaal Gewicht</th><th>PB Nummers</th></tr>";
             // output data of each row
             while($row = $result->fetch_assoc()) {
                 echo "<tr><td>" . $row["ExportID"]. "</td><td>" . $row["Debiteur"]. " " . $row["Deb_Name"]. "</td></tr>"
                 . $row["Tot_Pallets"]. "</td><td>" . $row["Tot_Weight"]. "</td><td>" . $row["PBS"]. "</td><td>"; 
             }
             echo "</table>";
        } else {
             echo "0 results";
        }

        $conn->close();
        ?>  
</body>
</html>

特罗尼奥斯出口公司

希望有人能帮助我:)

您错过了查询中的选择:

$sql = "SELECT ExportID, Debiteur, Deb_Name, Tot_Pallets, Tot_Weight, PBS FROM export";
$sql=“出口标识、借方、借方名称、托托托盘、托托重量、出口PBS”??你怎么错过了选择??