Jump to content

Read/Unread Record


kelidel
Go to solution Solved by mogosselin,

Recommended Posts

Hi, I am learning pdo php and mysql

 

I would like to know how to see whether a record has been read or not.  I have a database messages with id, user_id, contact_id, login, msg, rrecord and msgtime.

 

The rrecord column has been set as 0 as default.  When the client clicks the msg link, I would like it to update the rrecord to 1.

 

Thanks.

Link to comment
Share on other sites

So?  When the link is clicked, update the record after delivering it to the client.  Your link is going to trigger some code, correct?  That code is going to go get the data and deliver it to the clicker, no?  So once your code has read the data do an update query of that record to update your count and then finish delivering the data to the client to be read.

Link to comment
Share on other sites

  • Solution

Another way to put it... When the user clicks on a link (or a button) to see their message, you're going to issue a request to output this message. Something like: SELECT * from Message WHERE id=3 ... or whatever.

 

Then, right after you did this request, do another one that will update this row:

UPDATE message SET read=true WHERE id=3

 

There's also something called a 'Trigger' in MySQL... so you could do it directly on the database and you wouldn't need any code, but this doesn't work with a SELECT (insert, delete and update only).  So, there's no way to know if a row has been read except to update something right after you've read it. ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.