我目前正在制作一个笔记网络应用,进展非常顺利。我已经完成了CRUD的CRD部分。但除此之外,我还有点隐私问题。
如果我做一个新的笔记,其他人可以看到。这有点吓人。我认为结尾的WHERE语句有问题,因为我将一个项分配给下一个项。我该怎么解决?
$usersname = "users";
$notename = "note";
$query = "SELECT $usersname.name, $notename.title, $notename.note, $notename.date FROM $usersname, $notename WHERE $usersname.name = $notename.name";
最佳答案
SELECT $notename.title, $notename.note, $notename.date
FROM $notename
WHERE $notename.name = $userAllowedToSee
或者
SELECT $notename.title, $notename.note, $notename.date
FROM $notename
JOIN $usersname ON $usersname.name = $notename.name
WHERE $usersname.name = $sessionUserName