Results 1 to 3 of 3

Thread: Hiding records from one user but not for another

  1. #1
    Join Date
    Oct 2013

    Question 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".

    PHP Code:
    SELECT FROM notices WHERE staffCat<='".$_SESSION['UserAccess']."' AND NOT EXISTS (SELECT FROM noticeseen WHERE user='".$_SESSION['UserName']."')"; 
    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)

  2. #2
    Join Date
    Aug 2004
    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.:
    PHP Code:
    "SELECT * FROM notices WHERE
    .$_SESSION['UserAccess']."'  AND 
      NOT EXISTS (
        SELECT * FROM noticeseen 
        WHERE notice_id=notices.notice_id AND user='"

    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Oct 2013
    Thanks, worked great.

    Knew it was something along those lines.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center