Thanks guys, one more question... I get much of what you are saying, but in the case of Humbug's suggestion. how is the "read" (tinyint) cloumn, suppsoed to indicate, or know to indicate that message has been read or not read? how would it become 0 or 1??
Thanks!
once the member goes to the "view" portion of the code, have it mark the message as read if it is unread. pretty simple.
also, when i was creating my system, which was a lot like humbugs', i found a major flaw. once someone deletes the message from the database, it will delete the message from the senders outbox as well. this is why i used an inbox and outbox table. they both refer to an instance the message table, so you can't delete the message itself.
to fix this problem i used something like this:
#DROP TABLE IF EXISTS `inbox`;
CREATE TABLE IF NOT EXISTS `inbox` (
`in_id` int(11) NOT NULL auto_increment,
`in_mem_id` int(11) NOT NULL default '0',
`in_mess_id` int(11) NOT NULL default '0',
PRIMARY KEY (`in_id`)
);
#DROP TABLE IF EXISTS `messages`;
CREATE TABLE IF NOT EXISTS `messages` (
`mess_id` int(11) NOT NULL auto_increment,
`mess_to` int(11) NOT NULL default '0',
`mess_from` int(11) NOT NULL default '0',
`mess_subject` varchar(200) NOT NULL default '',
`mess_text` longtext NOT NULL,
`unread` int(11) NOT NULL default '0',
`time` int(11) NOT NULL default '0',
PRIMARY KEY (`mess_id`)
);
#DROP TABLE IF EXISTS `outbox`;
CREATE TABLE IF NOT EXISTS `outbox` (
`out_id` int(11) NOT NULL auto_increment,
`out_mem_id` int(11) NOT NULL default '0',
`out_mess_id` int(11) NOT NULL default '0',
PRIMARY KEY (`out_id`)
);
then to keep your database running smoothly, have cron job that will check if a message is not in a members inbox or outbox and if its not delete it.