I am writing a live chat function for a client, I have everything working up to the point of entering the conversation into a table on the server, however when it comes to ajax and jquery, I am still trying to get the basics down so here is my chat room code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
session_start();
include 'conection.php';
$name = $_GET['name'];
$query = "SELECT * FROM chatSession WHERE user_name = '$name'";
$result = mysql_query($query, $con) or die(mysql_error());
$row = mysql_fetch_array($result);
if(isset($_GET['submitmsg']))
{
$message = mysql_real_escape_string($_GET['usermsg']);
$throw = "INSERT INTO chatRoom(session_id, source, message, timestamp) VALUES('".$_GET['id']."', '".$_GET['source']."', '$message', UNIX_TIMESTAMP())";
if (!mysql_query($throw,$con))
{
die('Error: ' . mysql_error());
}else
{
//loadLog();
}
}
?>
<head>
<title>Platinum Motor Group-Live Chat</title>
<link type="text/css" rel="stylesheet" href="css/chatStyle.css" />
</head>
<body>
<div id="wrapper">
<div id="menu">
<p class="welcome"><b>Welcome, <?php echo $row['user_name']; ?></b></p>
<p class="logout"><a href="nameSub.php?logout=true&name=<?php echo $row['user_name']; ?>&id=<?php echo $row['session_id']; ?>">Exit Chat</a></p>
<div style="clear:both"></div>
</div>
<div id="chatbox">
</div>
<form name = "message" action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "get">
<input type = "hidden" name = "name" value = "<?php echo $_GET['name']; ?>" />
<input name = "id" type = "hidden" value = "<?php echo $row['session_id']; ?>" />
<input name = "source" type = "hidden" value = "<?php echo $row['user_name']; ?>" />
<input name = "usermsg" type = "text" id = "usermsg" size = "63" />
<input name = "submitmsg" type = "submit" id = "submitmsg" value = "Send" />
</form>
</div>
<script type="text/javascript">
$(document).ready(function()
{
//setInterval(loadLog, 5000);
});
</script>
</body>
</html>
I am wanting the information to show up in the chatbox div, here is the code I am using to retrieve the information
include'conection.php';
$sess = $_get['sess'];
$get = "SELECT * FROM chatRoom WHERE session_id = '$sess'";
$hold = mysql_query($get, $con) or die(mysql_error());
I am quite uncertain if any other information is needed, if it is then please let me know, the only thing that I am certain of when it comes to the code I need to write is that I need to target the function and the chatbox div, going over the information on w3schools.com, I am still a bit confused on how to accomplish any of this. Thank you in advance for any information or code you can provide.