如何显示数据库中与特定用户不是朋友的用户列表 [英] How to display list of users in a database that are not friends with a particular user

查看:42
本文介绍了如何显示数据库中与特定用户不是朋友的用户列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个系统,以显示所有尚未与特定用户建立朋友的用户,以便用户只能看到添加不是他们朋友的朋友,但我的问题是代码只删除了用户朋友在添加好友列表中,它会在添加friend_list中显示其他朋友,这已经是他的朋友,我需要帮助,请有人修理我的代码。



< b>我尝试了什么:



am trying to build a system to show all users that are not already friends with a particular user,so that users could only see add friends which are not their friends already,But my problem is that code with only remove the user first friend in the add friend list and it will show the rest of friends in the add friend_list which are already his friend i need help please someone should fix my code.

What I have tried:

if(isset($_SESSION['em'])){
 $eml = $_SESSION['em'];
 
 
 $list = "select friend_id,user_id from friend";
 $friend = mysqli_query($conn,$list);
 $rowf = mysqli_fetch_assoc($friend);
 
 $idf = $rowf['friend_id'];
 $id = $rowf['user_id'];

$query = ("select id,fst,las,uid,pass,email,sts,ocp from Users where email!='$eml' AND  id!='$idf' AND id!='$id'");
$res = mysqli_query($conn,$query);
 
if(mysqli_num_rows($res) > 0){

 
 while($row = mysqli_fetch_assoc($res)){
$_SESSION['ids'] = $row['id'];

 
 ?>




<table id="list">
 <tr>
 <td id="id" style=" "><a href=""><?php echo $_SESSION['ids'].'<br>';?></a></td>
 <td id="fst" style=""><a href="profile.php?uid=<?php echo $row['uid']; ?>"><?php echo $row['fst'].'<br>';?></a></td>
 <td id="las" style=""><?php echo $row['las'].'<br>';?></td>
 
 <td id="uid" style=" "><?php echo $row['uid'].'<br>';?>
<form action="request.php" method="POST">
  <a href="request.php?id=<?php echo $_SESSION['ids']; ?>"><input id="request" type="text" value="ADD" readonly></a></form></td>
 
 <td id="email" style=" width:180px;height:40px;text-align:center;"><?php echo $row['email'].'<br>';?></td>
 <td id="sts" style=""><?php echo $row['sts'].'<br>';?></td>
 <td id="ocp" style=""><?php echo $row['ocp'].'<br>';?></td>
 
 </tr>
 </table>
 <?php
 }
}
}
 ?>

推荐答案

_SESSION [' em'])){
_SESSION['em'])){


eml =
eml =


_SESSION [' em'];


_SESSION['em'];


这篇关于如何显示数据库中与特定用户不是朋友的用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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