doutuobao4004 2017-09-24 13:52
浏览 43

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

this is my first post and im already totally confused about my project right now :x

im able to make a successful connection to the sql db and also receive my data which displays on the top left, BUT its supposed to display in a html table, not somewhere on the screen :O

Here is the website to see the code in action, though there is none yet! http://blackskill.square7.ch/

Here is the code which is running fine, but maybe im just too stupid and new for coding yet 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>

i hope we can find an answer together with friendship, emotions and friendship!

regards

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?