I received some great help on my last question. Here is where I'm at:
I'm on the very last step of building a threaded messaging system for a dating website project for school and want to highlight a with a different bg color when a message is new. This is the table structure:
CREATE TABLE `messages`
(
`id` bigint (20) NOT NULL AUTO_INCREMENT ,
`fromme` integer (11) NOT NULL,
`tome` integer (11) NOT NULL,
`subject` varchar (255) NOT NULL,
`message` longtext NOT NULL,
`mydate` datetime NOT NULL,
`thread` varchar (255) NOT NULL,
`receipt` varchar (50) NOT NULL,
`INDELETE` varchar (5),
`SENTDELETE` varchar (5),
PRIMARY KEY (`id`)
) TYPE=MyISAM CHARACTER SET latin1 COLLATE latin1_swedish_ci;
This query determines if there are new messages (works correctly):
select * from messages where tome = '$yes' && receipt = 'n' and INDELETE !='y';
It then displays for example "3 New Messages."
All this displays correctly. The only problem is the inbox. Ollie Jones and Bill Karwin supplied me with some great help and it does work as intended, however when you return to the inbox after replying, that message is now gone.
SELECT messages.id,
messages.fromme,
messages.subject,
messages.message,
messages.receipt,
messages.mydate,
messages.thread,
users.firstname, users.lastname, users.image1
FROM messages,
users,
(SELECT MAX(messages.id) id, messages.thread thread
FROM messages
GROUP BY messages.thread) latest,
WHERE messages.tome = '$yes'
AND messages.INDELETE !='y'
AND messages.fromme = users.id
AND messages.id=latest.id
ORDER BY messages.mydate desc
The goal is to keep all of the messages in the inbox, just highlighting the new ones as above and grouping them by thread. Any ideas? Thanks JC