If the table was as follows (I've renamed user_id
, post
, and favorites
columns to clarify their roles as I understand them)
-------------------------------------
|Users |posts |favorites |
|-----------|-----------|-----------|
|id |id |id |
|username |title |uid |
|password |post_text |post_id |
| |uid | |
| |fav_id | |
-------------------------------------
This sql code can be used to get what (I think) you want
SELECT * FROM favorites
LEFT JOIN posts ON favorites.id = posts.fav_id
LEFT JOIN users ON posts.uid = users.id
WHERE favorites.uid='$id' and posts.active=1
This should get all the details of favorite posts from the three tables for the given user id. Hope it works for you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…