我制作了登录表单,当用户登录时,我将他的凭据存储在 SESSION
中。其中一行是 usertype
,它对每个用户都是唯一的。现在我有两张 table 。表 users
id
...
usertype
第二个表是 hauses
,它也有行 usertype
。
第三个表是user_hauses
hause_usertype
user_usertype
现在我正在尝试当用户使用 usertype=1
登录时将此 1
存储到 session 中,并在单击 Hauses
按钮时加载只有数据库中带有 usertype=1
的那一行。尝试过此查询,但到目前为止没有成功。
$q = mysqli_query($con, "SELECT * FROM `houses` AS c
LEFT JOIN `user_hauses` AS h2u ON c.hause_id = r2u.user_id
LEFT JOIN `users` AS u ON h2u.user_id = u.usertype");
最佳答案
看起来像打字错误,请参阅第 2 行末尾将 r2u 更改为 h2u
$q = mysqli_query($con, "SELECT * FROM `houses` AS c
LEFT JOIN `user_hauses` AS h2u ON c.hause_id = h2u.user_id
LEFT JOIN `users` AS u ON h2u.user_id = u.usertype");
关于php - 根据用户类型仅显示来自 mysql 的一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27279424/