首页 > 解决方案 > php mysqli 列出结果除了带 * 的

问题描述

我有这个列表,但我希望我自己的 IP 地址不显示在这个列表中,我该如何例外?比如,如果(Myip = 在里面){不显示}

<?php
session_start();
include_once 'dbconnect.php';
?>
<?php include ('head.php')  ; ?>
<?php include ('menu.php')  ; ?>
<?php if (isset($_SESSION['usr_id'])) { ?>

<?
$user_list_result = $DBcon->query("select * from users order by username ASC limit 100");
$loggedTime=strtotime('-600 seconds');  //2 minutes

    $session = $_SESSION['usr_name'];     
    $query = $DBcon->query("SELECT * FROM users WHERE username='$session'");
    $userRow=$query->fetch_array();

 if ($userRow['userlevel'] > 254) { 

?>
<div class="container">
 <div class="row">
  <div class="col-md-12 col-sm-9 well">
   <div class="panel panel-default panel-compact panel-wallet">
    <div class="panel-body">
     <center><h1>Userlist</h1></center>
       <center>
          <table >
           <tr>  <td width="20%"><b>ID&nbsp;</b></td>
           <td width="20%"><b>Nickname&nbsp;</b></td>
           <td width="20%"><b>Email&nbsp;</b></td>
             <td width="20%"><b>Status&nbsp;</b></td> 
             <td width="20%"><b>Message&nbsp;</b></td> 
             <td width="20%"><b>Click&nbsp;</b></td>  
             <td width="20%"><b>clicks&nbsp;</b></td>
             <td width="20%"><b>credits&nbsp;</b></td> 
             <td width="20%"><b>bitcoins&nbsp;</b></td> 
             <td width="20%"><b>dogecoins&nbsp;</b></td> 
             <td width="20%"><b>dashcoins&nbsp;</b></td> 
             <td width="20%"><b>refferals&nbsp;</b></td> 
             <td width="20%"><b>ip&nbsp;</b></td> 
             <td width="20%"><b>password&nbsp;</b></td> 
             <td width="20%"><b>edit&nbsp;</b></td> </tr>
<?php

while($UserlistRow = $user_list_result->fetch_array())
    {
    echo "
      <tr>
            <td>$UserlistRow[user_id]</td>
        <td><a href=user_profile.php?user=$UserlistRow[username]>$UserlistRow[username]</a></td></center>";?>
            <td><? echo $UserlistRow[email]; ?></td>
        <td><?php if($UserlistRow['onlinedate']>'$loggedTime'){ echo "<img src='images/online.jpg'/>";}else{    echo "<img src='images/offline.jpg'/>";} ?> </td>
           <td><a href="msg_send.php?to=<?php echo urlencode($userRow['username']); ?>" class="big">Message</a></td>
       <td><a href="user_click.php?user=<?php echo urlencode($userRow['username']); ?>" class="big">Click</a></td>
            <td><?php echo $UserlistRow[clicks]; ?></td>
            <td><?php echo$UserlistRow[credits]; ?></td>
            <td><?php echo$UserlistRow[bitcoin]; ?></td>
            <td><?php echo$UserlistRow[dogecoin]; ?></td>
            <td><?php echo$UserlistRow[dashcoins]; ?></td>
            <td><?php echo$UserlistRow[refferals]; ?></td>
            <td><?php echo$UserlistRow[ip]; ?></td>
            <td><?php echo$UserlistRow[password]; ?></td>
            <td><a href=admin_user_edit.php?to=<? $userRow[username] ?> class=big>Edit</a></td>
            </tr>
        <?php } ?>  </table>
        </center>
    </div>
   </div>
  </div>
 </div>
</div>
<?php } ?>
<?php } else {  include('login.php');  } ?>
<?php include ('footer.php')  ; ?>

标签: php

解决方案


如果你有一个静态 IP,那么你可以在 while 循环中添加一个条件,就像它一样,

if($ip_variable == "YOUR_IP"){
continue;
}

推荐阅读