PHP 在表中列出 SQL 数据库中的用户 [英] PHP List Users from SQL Database in Table

查看:50
本文介绍了PHP 在表中列出 SQL 数据库中的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图将所有用户放入数据库中,将表放入 html 表中,这就是我所拥有的:

Hi so im trying to put all of the useres in a database, table into a html table this is what i have:

<table class="table table-striped">
    <thead>
        <tr>
            <th>UUID</th>
            <th>Full Name</th>
            <th>Email</th>
            <th>Access Key</th>
            <th>Phone Number</th>
            <th>Activated</th>
            <th>Role</th>
        </tr>
    </thead>
    <tbody>

        <?php
        include_once('inc/conf/databaseConnect.php');
        $query = mysql_query("SELECT * FROM list_users ORDER by id");
        while($row = mysql_fetch_array($query)){
            echo "<tr>";
            echo "<td>".$row['uuid']."</td>";
            echo "<td>".$row['firstname'].$rowtwo['lastname']."</td>";
            echo "<td>".$row['email']."</td>";
            echo "<td>".$row['security_key']."</td>";
            echo "<td>".$row['phone_no']."</td>";
            echo "<td>".$row['activated']."</td>";
            echo "<td>".$row['role']."</td>";
            echo "</tr>";
        }
        ?>

    </tbody>
</table>

这不会返回任何内容或任何错误.它正确连接到数据库我检查过它只是没有检索用户.

This dosnt return anything, or any errors. It connects to the database correctly ive checked that its just not retrieving the users.

数据库结构图

databaseConnect.php:

databaseConnect.php:

    <?php

//Create Connnection
$sqlLink = mysqli_connect('localhost', 'root', 'classified', 'user_details');

//If Error Connecting
if(!$sqlLink) {
    die('<center><br><h3>Error connecting to servers Database.');
}

?>

推荐答案

谢谢.我已经解决了我更新为使用 mysqli 的方法的问题

Thanks. I have fixed the issue i updated to using mysqli's methods

<?php
include_once('inc/conf/databaseConnect.php');
$query = $sqlLink->query("SELECT * FROM list_users ORDER by id");
while($row = $query->fetch_array()){
    echo "<tr>";
    echo "<td>".$row['uuid']."</td>";
    echo "<td>".$row['firstname'].$row['lastname']."</td>";
    echo "<td>".$row['email']."</td>";
    echo "<td>".$row['security_key']."</td>";
    echo "<td>".$row['phone_no']."</td>";
    echo "<td>".$row['activated']."</td>";
    echo "<td>".$row['role']."</td>";
    echo "</tr>";
}
?>

这篇关于PHP 在表中列出 SQL 数据库中的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆