Imnotanerd
Imnotanerd

Reputation: 1167

Seeing other peoples posts

I'm currently making a note web app that going pretty well. I have the CRD part of CRUD finished. But besides that, I'm having a bit of an issue with privacy.

If I make a new note, Other people can see it. This is a bit scary. I think it's a problem with the WHERE statement at the end, because I'm assigning one item to the next. How can i fix this?

$usersname = "users";
$notename = "note";
$query = "SELECT $usersname.name, $notename.title, $notename.note, $notename.date FROM $usersname, $notename WHERE $usersname.name = $notename.name";

Upvotes: 1

Views: 58

Answers (1)

corsiKa
corsiKa

Reputation: 82589

SELECT $notename.title, $notename.note, $notename.date
FROM $notename
WHERE $notename.name = $userAllowedToSee

OR

SELECT $notename.title, $notename.note, $notename.date
FROM $notename
JOIN $usersname ON $usersname.name = $notename.name
WHERE $usersname.name = $sessionUserName

Upvotes: 1

Related Questions