dryb38654 2018-09-01 08:18
浏览 44

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

    <!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.

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.

Database: https://i.stack.imgur.com/qc1v4.png

Account table: here

  • 写回答

1条回答 默认 最新

  • dpk20361 2018-09-01 08:51
    关注

    Hey what you are showing here is not the data but the column definition

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

    But what you are querying here is the data in the accs table

    $sql= "SELECT account FROM accs";

    I believe there is no data in the accs table but you assume the column definition is data

    As you are using phpMyAdmin use the browse button to check whether you have any data in the table

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度