Jump to content

Recommended Posts

You need to explain what you think you mean by "read/unread system". As I explained when you originally posted about the inbox system, you need to be clear about what you're trying to do, rather than assuming we can read your mind. 

 

What exactly do you want to accomplish? If you can explain it in plain english, you can probably figure out how to do it in PHP/MySQL.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392096
Share on other sites

So you've explained your specifications now.

Messages are either read or unread. When someone looks at a message, you would change it to read.

 

Where are you stuck??? What have you done? You're acting like it's some kind of magic system - you need to write the code. To write the code you need to be able to say what the code should do. It sounds like you have said what the code should do - now do it...

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392099
Share on other sites

Um, tbh - if i knew how to go about doing it, I wouldn't be posting here... would I?

 

Ass in, what does my database need in it as all it has at the moment is the simple things like; content, message id, from, to, subject... what else is needed?

Maybe give me some links to look at or some sample code that I can build on, I have tried looking on the internet but nothing seems to do what I need it to do.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392165
Share on other sites

It's just logic.

 

You want to store if a message has been read or not. 

What would you add to your table? You want to store ONE THING that is a boolean. Is it really THAT HARD to figure out what you change in your table? You need to start thinking a little instead of assuming you'll find it on the internet. 

 

We are here to help but you are not doing any of this work on your own.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392174
Share on other sites

Then you didn't do a very good job of explaining the functionality that you were looking for. You said nothing about the sender still having visiblity of the message after it was sent, or having a read flag on the sender side (I assume you want that just incase they typed the message with their eyes closed?)

 

I know it sounds like were all being a bit harsh and getting on your back here, but it is for your benefit that we are doing it. It's one of the most frustrating things (I personaly would put it right up there with a baby crying for no good reason) in the word when you get an unclear or ambiguous job spec. Please try and be as explicit and verbose about what you are looking for as you can be.

 

That said - you gave the impression that you needed a single flag : you were then told to insert a single enum column (although bit would be just as good)

- It turns out that you actulay want two flags.......

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392211
Share on other sites

How about read_sender and read_recipient (I always find it nice when tables have relevent column names)? assuming you have both sender_id and a recipient_id stored in the table against the message then you simply check which of these two the current user id matches and update the table to set the relevent field accordingly.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392235
Share on other sites

My 2 cents:

 

Database should look something like this :

 

id | subject | body | sender | recipient | read

 

When a new message is created "read" would be set to 0, when the user reads it that would be updated to 1. As far as how you go about it, its up to you. You said avoid Javascript in that case you could provide an "Inbox" list of message and when a user opens the full message , set the read field to 1...

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392262
Share on other sites

How is it possible the sender would NOT have read it? Why even bother showing the sender the status?

That's what I'm confused about too - of course the sender read it, they wrote it. It should change from read to unread when the recipient reads it. 

 

I wonder if she's talking about a message thread like in Gmail? 

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392289
Share on other sites

Showing the sender that the message is unread is actually good because that way the sender will know whether it has been read or not, however if you don't want this kind of functionality the easiest way is to check if it is the sender who is viewing the message at the time and not mark it as unread.

 

because of my bad English I'm going to explain this in a simpler way

 

in your php document do this

 

retrieve the "read" value ( 0 or 1 ) from your db and using an IF statement checking if the current user is the sender don't apply styles for unread message

Edited by Manixat
Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392291
Share on other sites

Why would the message be IN the sender's INBOX?

It should be in a SENT folder.

 

If you're showing an "all messages" view (again, like gmail), you still don't show sent messages. When you're showing the sent messages, you wouldn't bold messages they sent unless you WANT to be able to show them it hasn't been read by the reader.

 

If you for some odd reason want to show sent messages in an inbox, you would use logic in PHP to determine the bolding - if they are the one that sent it, you don't want it bold (based on your last post), so use that logic - not the read/unread field.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392298
Share on other sites

The read/unread status only applies to the recipient. You would only use it for highlighting when the current user is the recipient, not when the current user is the sender. The messages in any user's 'in box' are when the current user = recipient. The messages in any user's 'out box' are when the user = sender. Messages someone sends aren't in their inbox.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392299
Share on other sites

Not a separate table - the php script that displays the messages should have options. You would select a folder, and the script would show you the messages in that folder. Common default folders would be Inbox and Sent. Also Trash sometimes. The script then uses simple logic to determine which messages to display from your single table.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392309
Share on other sites

You have been given several answers to this issue already. Not much more anyone can do for you. Apply the advice that was given to you and if you are still having issues with the code after you have attempted to implement the logic given to you, post back with all relevant code and your issue.

Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1392314
Share on other sites

  • 1 year later...

Hi , hello :) zombie here , 

 

i also want to create this INBOX SYSTEM too but i'm a little bit confuse with some php code .can anybody help me ? please ... thank you . i already start some code . i just now need to connect this into database so that all unread emails will be going to write to database . what code i will use ? hihi ... i'm a newbie :)really appreciate with ur help 

 

im  :confused: :(

 

-----------------------------------------------------

 

<?php

 
 
function unread_emails ($username , $password){
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
 
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
 
/* grab emails */
$emails = imap_search($inbox,'UNSEEN');
echo count($emails)." ";
echo "<pre>".print_r($emails,true)."</pre>";
//die;
 
 
/* if emails are returned, cycle through each... */
if($emails) {
    $i=0;
/* begin output var */
$output = '';
 
/* put the newest emails on top */
rsort($emails);
 
/* for every email... */
foreach($emails as $email_number) {
        $i++;
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,1);
 
/* output the email header information */
$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
$output.= '<span class="from">'.$overview[0]->from.'</span>';
$output.= '<span class="date">on '.$overview[0]->date.'</span>';
$output.= '</div>';
 
/* output the email body */
$output.= '<div class="body">'.$message.'</div>';
 
        //if{$i==10} break;
}
 
echo $output;
}
 
/* close the connection */
imap_close($inbox);
}
 
unread_emails ('**********@gmail.com' , '*******' );
 
?>
Link to comment
https://forums.phpfreaks.com/topic/270638-readunread-messages/#findComment-1481343
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.