我使用以下查询通过将表单数据与图像数据连接来显示记录。
SELECT * FROM soccer JOIN soccerimages ON soccer.id = soccerimages.id ORDER BY soccer.id
这将显示所有记录,包含一个图像的表单数据,但如何仅显示登录用户的记录?如果用户从网站上传图片,我需要将其设为私有以避免版权问题。登录用户存储在会话变量
中$user = $_SESSION['UserName'];
我累了
SELECT * FROM tcgsoccer JOIN tcgsoccerimages ON tcgsoccer.id = tcgsoccerimages.id ORDER BY tcgsoccer.id `WHERE '$user'='$user'`
但我得到语法错误。我不明白如何构建查询?我在phpmyadmin中测试它,所以删除了;
答案 0 :(得分:0)
$query = "SELECT *
FROM tcgsoccer
JOIN tcgsoccerimages ON tcgsoccer.id = tcgsoccerimages.id
ORDER BY tcgsoccer.id
WHERE user = '" . $user ."'";