Hiding records from one user but not for another
Set up a website that allows a management user to add/edit/delete notices for staff users to read.
Upon reading, staff users can select "Mark as seen" and the idea is that it hides for them, but not for other users - however, the query I'm using doesn't seem to be working properly in that if I had notice1, notice2 and notice3 once "user1" hides "notice1", no notices appear for "user1".
Obviously I believe this to be in the 2nd half of the query, however,can't figure out how to limit to where user & id(noticeseen) = user(logged in) & id(notices)
SELECT * FROM notices WHERE staffCat<='".$_SESSION['UserAccess']."' AND NOT EXISTS (SELECT * FROM noticeseen WHERE user='".$_SESSION['UserName']."')";
I would think that the noticesceen table would include both a "user" and "notice_id" (or whatever name you used?) column? Assuming it does, then your not-exists sub-query would need to include it in the where clause, e.g.:
"SELECT * FROM notices WHERE
NOT EXISTS (
SELECT * FROM noticeseen
WHERE notice_id=notices.notice_id AND user='".$_SESSION['UserName']."'
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks, worked great.
Knew it was something along those lines.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread