simple query,but it's giving me a headache, i need a division to be updated with a changed session variable each time a user clicks on a name,i figured i'd use .html() using jquery to update the division, i don't know if you can do this, but here goes:
$("#inner").html('<?php
session_start();
if(file_exists($_SESSION['full'])||file_exists($_SESSION['str'])){
if(file_exists($_SESSION['full']))
{
$full=$_SESSION['full'];
$handlle = fopen($full, "r");
$contents = fread($handlle, filesize($full));
fclose($handlle);
echo $contents;
echo '<script type="text/javascript" src="jquery-1.8.0.min (1).js">';
echo '</script>';
echo '<script type="text/javascript">';
echo 'function loadLog(){
var oldscrollHeight = $("#inner").attr("scrollHeight") - 20;
$.ajax({
url: \''.$_SESSION['full'].'\',
cache: false,
success: function(html){
$("#inner").html(html); //Insert chat log into the #chatbox div
var newscrollHeight = $("#inner").attr("scrollHeight") - 20;
if(newscrollHeight > oldscrollHeight){
$("#inner").animate({ scrollTop: newscrollHeight }, \'normal\'); //Autoscroll to bottom of div
}
},
});
}
setInterval (loadLog, 2500);';
echo '</script>';
}
else
{
$str=$_SESSION['str'];
if(file_exists($str))
{
$handle = fopen($str, 'r');
$contents = fread($handle, filesize($str));
fclose($handle);
echo $contents;
$full=$_SESSION['full'];
$handlle = fopen($full, "r");
$contents = fread($handlle, filesize($full));
fclose($handlle);
echo $contents;
echo '<script type="text/javascript" src="jquery-1.8.0.min (1).js">';
echo '</script>';
echo '<script type="text/javascript">';
echo 'function loadLog(){
var oldscrollHeight = $("#inner").attr("scrollHeight") - 20;
$.ajax({
url: \''.$_SESSION['str'].'\',
cache: false,
success: function(html){
$("#inner").html(html); //Insert chat log into the #chatbox div
var newscrollHeight = $("#inner").attr("scrollHeight") - 20;
if(newscrollHeight > oldscrollHeight){
$("#inner").animate({ scrollTop: newscrollHeight }, \'normal\'); //Autoscroll to bottom of div
}
},
});
}
setInterval (loadLog, 2500);';
echo '</script>';
}
}
}
?>');
is that legal, if not, how would i accomplish this?