Amit Verma
Amit Verma

Reputation: 41219

Read or unread message status with php mysql

I have a messaging system on my site where users can send messages to one another, I have a mysql database with the following columns in it :

 id sentto sentby msgbody created

"sentto" is the person to whom msg is sent. "sentby" is the msg sender.

I use select statement to display msg on page.

Now i want to add status function Read|unread to my msging system, so that if foo sends a msg to bar ,bar opens his inbox and reads the msg, then foo will see status Read in outbox for the msg.

How is this possible?

Do I need to create 2 more columns "read" "unread" in my chat table?

Any idea?

Upvotes: 0

Views: 1891

Answers (1)

Brian
Brian

Reputation: 1025

Add a new column hasread, tiniyint (1), default as 0 after sentby. When the receiver (bar) opens the message update the db record hasread = 1.

Upvotes: 1

Related Questions