I am working on a anouncement system.
the announcements are displayed everywhere in the website, every anouncement has a acknowledge button, basicaly to mark it as seen.
what i have:
Table: announcements: annId, annTitle, annContent, annDatetime
Table: annComplete: annCompletedId, annId, userId, annCompleteDatetime
I first pull all the announcements from the table
$result = mysqli_query($link, "SELECT * FROM announcements"); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) {
durring the while portion I go to the annComplete:
$check = mysqli_query($link, "SELECT * FROM annComplete WHERE
userId= "$userId" AND
annId= '".$row['annId']."'"); if(mysqli_num_rows($check) == 0){
in here I check if there was an entry here. if there is, then I dont display the announcement (user marked it as read)
question, is there a better way of doing this?
I have to display the announcements that are not marked as read.
thanks you