kelidel Posted October 29, 2014 Share Posted October 29, 2014 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. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 29, 2014 Share Posted October 29, 2014 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. Quote Link to comment Share on other sites More sharing options...
Solution mogosselin Posted October 29, 2014 Solution Share Posted October 29, 2014 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. Quote Link to comment Share on other sites More sharing options...
kelidel Posted October 30, 2014 Author Share Posted October 30, 2014 Thank you friends. I appreciate your guidance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.