[英]Enter into MySQL table column a user name if selected by a user who has also chosen them using php
[英]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
我正在嘗試創建一個社交媒體原型,用戶可以在其中登錄、添加其他人、向其他人發送小文件等。在添加朋友頁面上,我打印了所有用戶名。 打印時我的名字也被打印出來了。 我想要的是從該列表中隱藏我的名字,以便我獲得除我之外的所有其他人的列表。
試試這個:
select * from table where user_name not in ($_SESSION["name"]);
select * from table where user_name != '$_SESSION["name"]';
從 php 會話中,您將獲得登錄用戶 ID,在您的 mysql 查詢中使用該用戶 ID,如下所示
$query = "select * from users where user_id not in(".$loggedInUserId.")";
其中$loggedInUserId
是 php 會話用戶 ID。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.