Jump to content

Mailbox System: If message hasn't been read display image


JohnnyKennedy

Recommended Posts

Hey There,

 

So I'm building a site, and part of this website allows users to message each other - I'm doing it through a PHP MySQL Database (I know it's probably not the best way :\ ).  I've got an inbox, outbox, sent & the actual send function working, but what I can't figure out is how to tell if the message has been read or not.

 

I was thinking of doing an integer kind of thing, for eg. I have a col in my database for 'read' with two possible values of 1 or 0 (1 being read, 0 being new).  Then I played around with IF statements, but can't figure out how to do it.

 

If you guys could maybe help me out with an IF statement that would let me show an Image if the value is 0.  My Recordset was done using DW, and I have a repeat region included.  Let me know what code you need, if you need any more - but heres the most relevant code. :)  Thanks in advance you guys.

 

 

$colname_inbox = "-1";

if (isset($_SESSION['MM_Username'])) {

  $colname_inbox = $_SESSION['MM_Username'];

}

mysql_select_db($database_NewConnection, $NewConnection);

$query_inbox = sprintf("SELECT * FROM mailboxes WHERE recipient = %s ORDER BY server_time DESC", GetSQLValueString($colname_inbox, "text"));

$query_limit_inbox = sprintf("%s LIMIT %d, %d", $query_inbox, $startRow_inbox, $maxRows_inbox);

$inbox = mysql_query($query_limit_inbox, $NewConnection) or die(mysql_error());

$row_inbox = mysql_fetch_assoc($inbox);

Link to comment
Share on other sites

I assume the users who receive the messages will click a link to read the message. You can add an UPDATE SQL to the code that handles the part when user wants to read a message and clicks the link. In this UPDATE you update the column 'read' to 1 for the message he just read.

Link to comment
Share on other sites

IF the 'read' field is 0 or 1 (int) maybe DEFAULT to 0. No need to compare to empty strings or null, just check the number of it. or even better just check against boolean

if ($row['read'])
{
    // Message is read
}
else
{
    // Message not read
}

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.