Hi all i have this code but what i am wanting to included in a certain functions and im wanting to get either jquery refresh or ajax to refresh multiple divs every second the only problem i have is that when i do try to include my page as jquery is asking its not sure who the username is but since the user required to be logged into joomla in order to view the page i get the whole layout being displayed for some reason

in that div when i have already told it to get profile.php what am i doing wrong here is my jquery code

Code HTML4Strict:
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
                <script type="text/javascript">
				$(document).ready(function() {
					 $("#right_contenta").load("profile.php");
 
				   var refreshId = setInterval(function() {
 
					  $("#right_contenta").load('profile.php');
 
				   }, 1000);
 
				});
				</script>

For the onload function im trying to figure out the same page but only certain items in that div ive tried to do seperate the files but not luck<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#right_contenta").load("profile.php");

var refreshId = setInterval(function() {

$("#right_contenta").load('profile.php');

}, 1000);

});
</script>

but nothing gets showed up on my left-handside of my joomla template the function of profile.php is just this

Code:
$user =& JFactory::getUser();
if($user->username)
{
	$t=$user->username;
	$cQuery="SELECT * FROM gg46_users WHERE username='$t'";
	$result=mysqli_query($con,$cQuery);
		if(!$result)
		{
			echo "Error:".mysqli_error($con);
		}
		else
		{
			$count=$result->num_rows;
			if($count>0)
			{
				//
				while($data=$result->fetch_assoc())
				{
					$c=$data['cexp'];
					$m=$data['mexp'];
					$cexp=$data['cexp'];
					$mexp=$data['mexp'];
					$aid=$data['awardid'];
					echo '<div id="p">
					<div id="Stats">
						<table>
						<tr>
							<th>'.$data['username'].'</th>
						</tr>
						<tr>
							<th>XP:'.$cexp.'/';
							if($mexp=="0")
							{
								echo "100";	
							}
							else
							{
								echo $mexp;
							}
							echo '</th>
						</tr>
						</table>
					 </div>
					 <div id="level">
					 	<div id="lvl">';
						echo "<span style='font-size:18px;'><b>".calclevel($c)."</b></span>";
						echo '</div>
					 </div>
					 <div id="progress">';
					echo progressbar($c,$m);
					echo '</div>
					</div>
					<div id="pics">
						<div id="inner">';
						if($aid=="")
						{
							$aid="1";
							echo getaward_by_id($aid);
						}
						else
						{
							echo getaward_by_id($aid);	
						}
						echo '</div>
					</div>
					';
				}
				//
			}
			else
			{
				echo "No Player Exists";	
			}
		}
		?><?
	//
}
But for some reason the whole layout gets displayed in that div one for asking user to login and another one showing the user that they have logged in.

So what am i doing wrong?
Can anyone help me here please?

Thanks,William