Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere to put the code to trigger marking notification as seen
    text
    copied!<p>I have a simple MySQL table for storing notification in a web with social networking feature written in PHP. </p> <pre><code>+----------------------+ | Notifications | +----------------------+ | (PK) notification_id | | user_id | | uri | | message | | seen | | created_at | +----------------------+ </code></pre> <ul> <li><strong>notification_id</strong> is PK (pretty self-explanatory)</li> <li><strong>user_id</strong> is the ID of user who gets the notification</li> <li><strong>uri</strong> is the internal URI where the browser will go when the user clicked the notification, mostly it links to the individual occured event page (such as linking to a user's photo permalink when the notification is about someone commenting at it)</li> <li><strong>message</strong> is the notification message</li> <li><strong>seen</strong> is stored as boolean, it indicates wether the notification has been read or not <em>(it is the most important part in this question)</em></li> <li><strong>created_at</strong> is just a timestamp</li> </ul> <p>I have done most of the notification mechanism, but the remaining is the seen/unseen part.</p> <p>I want to show only the unseen notification in the dropdown menu in the top navigation bar (like Facebook does), and the user can click a link to the page showing all notifications.</p> <p>Where is the best place to put the code to trigger marking it as seen? It should be marked 'seen' when the designated user has read the notification content and get to the individual event page (ie. by clicking it)</p> <p>I have thought of some methods, another alternatives are welcome.</p> <ul> <li>Using javascript to intercept user's click on notification and make ajax request to 'mark as seen' before proceeding to notification's URI</li> <li>Make PHP script in the destination URL to update the <strong>seen</strong> record in the database. The problem with this method is there is no <em>relationship</em> between the individual post with the notification record. </li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload