繁体   English   中英

我的 php 代码说我在数据库中没有任何东西,尽管我有。 我的代码有什么问题?

[英]My php code is saying I do not have anything in database, although I do. Whats wrong with my code?

    <!DOCTYPE html>
    <html>
    <head>
        <title>Tiger-Gen</title>

        <!-- Compiled and minified CSS -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css">

        <!-- Compiled and minified JavaScript -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
                <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
    <link rel="stylesheet" href="main.css">
    </head>

    <body>
        <style>
        .font1 {
            font-family: 'Raleway', sans-serif;
        }
    </style>
        <div class=" container center-align font1 y">
        <h1 class="yeet big">Tiger-Gen</h1>
    <?php 
    include ("connection.php");
        $sql= "SELECT account FROM accs";
        $result = mysqli_query($conn, $sql);

        if (mysqli_num_rows($result) > 0) {
            //output account
            while($row = mysqli_fetch_assoc($result)) {
                echo $row["account"];
            }
        } else {
            echo "nothing";
        }

        mysqli_close($conn);
        ?> 

        <a class="waves-effect waves-light btn center-align btn-large">Generate</a>
    </div>
    </body>




    </html>

Here is my html and php code, I have read over it many and many times and changed my php code multiple times. As you can see it outputs "Nothing" when nothing is in the database. But the problem is there are things in the database, any help is appreciated.

这是我的 html 和 php 代码,我已经阅读了很多次并多次更改了我的 php 代码。 如您所见,当数据库中没有任何内容时,它会输出“Nothing”。 但问题是数据库中有东西,任何帮助表示赞赏。

数据库: https : //i.stack.imgur.com/qc1v4.png

账户表:这里

嘿,您在此处显示的不是数据,而是列定义

https://i.stack.imgur.com/RaEOQ.png

但是你这里查询的是accs表中的数据

$sql= "SELECT account FROM accs";

我相信 accs 表中没有数据,但您假设列​​定义是数据

当您使用 phpMyAdmin 时,请使用浏览按钮检查表中是否有任何数据

暂无
暂无

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

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