将我的db表转换为html表没有结果

时间:2017-09-24 13:52:33

标签: php html mysql database

这是我的第一篇文章,我现在已经完全混淆了我的项目:x

我能够成功连接到sql db并且还接收显示在左上角的数据,但它应该显示在html表中,而不是显示在屏幕上的某个位置:O

这是在网站上查看代码的实际操作,但还没有! http://blackskill.square7.ch/

这是运行良好的代码,但也许我只是太愚蠢和新编码而xd

<!DOCTYPE html>

<?php

$connection=mysqli_connect("localhost","username","password","db_name");

if ($connection) {
    echo "database online <br>";
} else {
    die("Connection failed. Reason: ".mysqli_connection_error());
}

$sql="SELECT * FROM blackskill_playerdb";
$results=mysqli_query($connection,$sql);

if (mysqli_num_rows($results)>0) {

    while($row=mysqli_fetch_array($results)) {

        echo   '<tr>
                <td>'.$row[0].'</td>
                <td>'.$row[1].'</td>
                <td>'.$row[2].'</td>
                <td>'.$row[3].'</td>
                </tr>';

        echo "<br>";

    }

}

mysqli_close($connection);

?>


<html>
<head>
    <style>
    * {
      box-sizing: border-box;
    }

    #myInput {
      background-image: url('/searchicon.png');
      background-position: 10px 10px;
      background-repeat: no-repeat;
      width: 20%;
      font-size: 16px;
      padding: 12px 20px 12px 40px;
      border: 1px solid #ddd;
      margin-bottom: 12px;
    }

    #myTable {
      border-collapse: collapse;
      width: 100%;
      border: 1px solid #ddd;
      font-size: 18px;
    }

    #myTable th, #myTable td {
      text-align: left;
      padding: 12px;
    }

    #myTable tr {
      border-bottom: 1px solid #ddd;
    }

    #myTable tr.header, #myTable tr:hover {
      background-color: #f1f1f1;
    }
    </style>
</head>
<body>

    <h2><center>Inofficial S.K.I.L.L. - Special Force 2 - Dishonor List</center></h2>

    <input type="text" id="myInput" onkeyup="aa" placeholder="Search for player..." title="Type in a name">

    <table id="myTable">
      <tr class="header">
        <th style="width:40%;">Player</th>
        <th style="width:20%;">Clan</th>
        <th style="width:20%;">Evidence</th>
        <th style="width:20%;">Added to list</th>

            <?php while($row=mysqli_fetch_array($results)) : ?>
            <tr>
                <td><?php echo $row['name']; ?></td>
                <td><?php echo $row['clan']; ?></td>
                <td><?php echo $row['rulebreak']; ?></td>
                <td><?php echo $row['addlist']; ?></td>
            </tr>
            <?php endwhile ?>

      </tr>
    </table>
    <tbody>

</body>
</html>

我希望我们能够在友谊,情感和友谊中找到答案!

问候

0 个答案:

没有答案