I am working on an online dating site. Members are able to send messages to other members, but they are as well able to send messages to moderators/administrators. To keep things clearly I would like to have a feature, that if it is an ongoing coversation between the member and the administrator where a certain moderator/administrator has answered a question and the member has replied to that answer, the answer will come back to the moderator/administrator that has answerd, but only if he/or she is online. Otherwise it should come in pool of unanswered messages for the other moderators/administrators that are online.
I am using PHP but would love to use Ajax as well so i don’t need any page refresh. Right now I have a page berichten (messages) in the admin panel. I am refreshing the page each 30 seconds using Ajax i.e.
$(function() {
startRefresh();
});
function startRefresh() {
setTimeout(startRefresh,30000);
$.get('berichten.php', function(data) {
$('#berichten).html(data);
});
}
and I have a table berichten (messages) with the following structure:
CREATE TABLE IF NOT EXISTS `berichten` (// messages
`bericht_id` int(4) NOT NULL AUTO_INCREMENT,
`member_id` smallint(4) NOT NULL, // The member who send the message
`bericht` text,
`admin` tinyint(2) NOT NULL DEFAULT '0', // This (on advise from Pullo) is to set the admin_id if he/she is online
PRIMARY KEY (`bericht_id`),
KEY `member_id` (`member_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
But from this point I really have no idea how to proceed? Any help would be highly appreciated