简体   繁体   English

如何不打印与使用 php 脚本登录的用户的会话名称相等的 mysql 表值

[英]how to not print a mysql table value which is equal to the the session name of the user who has logged in using a php script

I am trying to create a social media prototype where user can log in, add others, send small file to others, etc. at the add friends page I have printed all the users name.我正在尝试创建一个社交媒体原型,用户可以在其中登录、添加其他人、向其他人发送小文件等。在添加朋友页面上,我打印了所有用户名。 when printing my name is also getting printed.打印时我的名字也被打印出来了。 what I want is to hide my my name from that list so that I get a list of all the other person except mine.我想要的是从该列表中隐藏我的名字,以便我获得除我之外的所有其他人的列表。

试试这个:

select * from table where user_name not in ($_SESSION["name"]);

select * from table where user_name != '$_SESSION["name"]';

from php session you will get loggin user id, use that userid in your mysql query like following从 php 会话中,您将获得登录用户 ID,在您的 mysql 查询中使用该用户 ID,如下所示

$query = "select * from users where user_id not in(".$loggedInUserId.")";

where $loggedInUserId is the php session user id.其中$loggedInUserId是 php 会话用户 ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM