php使用连接显示mysql中的数据

93ze6v8z  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(294)

我使用php5.6,我有php错误和一切,我没有得到。
我的php代码

$GetAllServers  = $db->select("SELECT * FROM panel_servers ORDER BY id ASC");
$GetAllGroups   = $db->select("SELECT * FROM panel_admin_groups ORDER BY id");
$GetAllAdmins   = $db->select("SELECT *, s.name server_name, g.name group_name, a.pid pid
    FROM panel_admins a 
    LEFT JOIN panel_players p ON a.pid = p.id 
    LEFT JOIN panel_admin_groups g ON a.gid = g.id 
    LEFT JOIN panel_countries c ON p.country = c.country_code 
    LEFT JOIN (SELECT `username`, `pid` FROM panel_players_username GROUP BY pid ORDER BY last_used DESC) u ON a.pid = u.pid 
        LEFT JOIN panel_servers s ON a.sid = s.id WHERE (TIMESTAMPDIFF(MINUTE, add_time, now()) < g.usetime OR g.usetime = 0) ORDER BY immunity DESC");

我的html代码

<?php
$Players = array();
foreach ((array)$GetAllAdmins as $admin)
    if(!in_array($admin['steamid'], $Players))
        array_push($Players, $admin['steamid']);
        $avatars = GetPlayersAvatars($Players);
?>
<?php foreach ((array) $GetAllAdmins as $admin) { 
    if(!empty($admin['steamid'])){?>
        <tr>
            <td class="coutryrow"><img src="<?=WEBSITE;?>/img/flag/<?=$admin['country_name'];?>.png" title="<?=$admin['country_name'];?>" class="flag"></td>
            <td>
                <a target="_blank" href="http://steamcommunity.com/profiles/<?=$admin['steamid'];?>">
                    <img src="<?=$avatars[$admin['steamid']]?>" class="player-avatar">
                    <?=(!empty($admin['player_username'])) ? htmlspecialchars($admin['player_username']) : htmlspecialchars($avatars['username-'.$admin['steamid']]);?>
                </a>
             </td>
             <td class="centerrow"><?=htmlspecialchars($admin['group_name']);?></td>
             <td class="centerrow"><?=htmlspecialchars($admin['server_name']);?></td>
             <td class="centerrow"><?=date(TIMEFORMAT, strtotime($admin['add_time']));?></td>
             <td class="centerrow"><a href="<?=$CurrentURL;?>edit/<?=intval($admin['aid']);?>/" class="btn btn-info btn-mini"><span class="icon"> <i class="icooo-on-edit"></i> </span><?= _("Edit");?></a></td>
         </tr>

         <?php } else {echo "<tr><td>-</td></tr>";} } ?>

我想在html中显示添加到数据库的所有管理员的列表,但是例如,名称在一个表中,标志在另一个表中。如您所见,连接和我想在html上显示的所有内容。

0md85ypi

0md85ypi1#

如果要在数据库中添加最后的管理员,请使用此查询

$GetAllAdmins   = $db->select("SELECT steamid, s.name server_name, g.name group_name, a.pid pid FROM panel_admins a 
                                        LEFT JOIN panel_admin_groups g ON a.gid = g.id 
                                        LEFT JOIN panel_servers s ON a.sid = s.id WHERE (TIMESTAMPDIFF(MINUTE, add_time, now()) < g.usetime OR g.usetime = 0) ORDER BY immunity DESC");

你需要3列。如果要添加筛选器,请将其添加到where子句中

相关问题