www.webdeveloper.com
Results 1 to 3 of 3

Thread: Hiding records from one user but not for another

  1. #1
    Join Date
    Oct 2013
    Posts
    3

    Question Hiding records from one user but not for another

    Hi,

    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
    Location
    Ankh-Morpork
    Posts
    19,326
    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
      staffCat<='"
    .$_SESSION['UserAccess']."'  AND 
      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

    eBookworm.us

  3. #3
    Join Date
    Oct 2013
    Posts
    3
    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



Recent Articles