I'm working on a chat application with HTML, jQuery, PHP and MySQL. My program looks like this: on the left you have users bar, where you can find all the users (the program also displays whether user is online or not, but this I can handle). When you click a user from the list, it generates a draggable container div that looks like this:
<div class="container"><div class="head"></div><div id="conversation"></div></div>
Specification: the "head" class is used just to display the partner's avatar and toggle the "conversation" div on click.
My problem:
I think I will load the conversation inside the "conversation" div using AJAX and JavaScript so it will refresh the div without refreshing the page. The user will have multiple user conversations opened at a time, so I need an idea about how to identify which conversation to load in each div. I'm stuck here.
Optional: I want the user to see when the partner has seen the message, but I think I can display "Seen at DATE." when the conversation
is set to visible. If you have another suggestion, feel free to explain.
Every information is taken from a MySQL database.
My PHP display function looks like this:
<?php
include_once('connect.php');
$you = $SESSION['user'];
$takeconversation = "SELECT * FROM conversations WHERE sender='$partner' AND receiver='$you' OR sender='$you' AND receiver='$partner'";
$dotake = mysqlquery($takeconversation);
?>
So $you
is the $SESSION['user']
, but I need to add an identifier to give a value to $partner
, so $partner
would have a different value for every conversation div.