<script>
setInterval(function(){
$.ajax({
url :'user_online.php',
success: function()
{
$('.chat-o').load('user_online.php');
}
});
},1000);
</script>
Let's say I have this script. How do I make it work if user_online is the file I put this in (meaning, how can I make this script work internally-- within a php file called the same as the url)
Basically I want to apply the same thing as above to another page make it auto display the results without having to reload it:
<?php
$gameid = fetchinfo("value", "info", "name", "current_game");
$query = mysql_query("SELECT * FROM `games` WHERE `id` < $gameid ORDER BY `id` DESC LIMIT 10");
while($rowd=mysql_fetch_array($query)):
//define stuff
$lastwinner=$rowd["userid"];
$winnercos =$rowd['cost'];
$winnerpercent = $rowd['percent'];
$winneravatar=fetchinfo("avatar", "users", "steamid", $lastwinner);
$winnername = fetchinfo("name", "users", "steamid", $lastwinner);
$steamlink = fetchinfo("steamprofile", "users", "steamid", $lastwinner); ?>
<div class="cont row">
<div class="col-xs-24 header">
</div>
<div class="col-xs-24 body">
<div class="col-xs-16 col-sm-16">
<a rel="nofollow" target="_blank" href=<?php echo $steamlink; ?> class="img hidden-xs">
<img src=<?php echo $winneravatar; ?> > </a>
<a rel="nofollow" target="_blank" href=<?php echo $steamlink; ?> class="name"> <?php echo $winnername; ?> </a>
</div>
<div class="right text-right">
<span class="win">
Win: <span>$ <?php echo round($winnercos, 3); ?> </span></span>
<span class="chance">
Chance: <span><?php echo round($winnerpercent, 2); ?>% </span> </span> </div> </div>
Updated it with what I wanted. Can anyone tell me if it's ok? This is from one part of index.php
<div class="site history col-xs-24 col-sm-18 col-md-14 col-lg-12"> <h2>History</h2> <div id="history">
<script>
setInterval(function(){
$.ajax({
url :'index.php',
success: function()
{
$('.history').html(data);
}
});
},1000);
</script>
<?php
$gameid = fetchinfo("value", "info", "name", "current_game");
$query = mysql_query("SELECT * FROM `games` WHERE `id` < $gameid ORDER BY `id` DESC LIMIT 10");
while($rowd=mysql_fetch_array($query)):
//define stuff
$lastwinner=$rowd["userid"];
$winnercos =$rowd['cost'];
$winnerpercent = $rowd['percent'];
$winneravatar=fetchinfo("avatar", "users", "steamid", $lastwinner);
$winnername = fetchinfo("name", "users", "steamid", $lastwinner);
$steamlink = fetchinfo("steamprofile", "users", "steamid", $lastwinner); ?>
<div class="cont row">
<div class="col-xs-24 header">
</div>
<div class="col-xs-24 body">
<div class="col-xs-16 col-sm-16">
<a rel="nofollow" target="_blank" href=<?php echo $steamlink; ?> class="img hidden-xs">
<img src=<?php echo $winneravatar; ?> > </a>
<a rel="nofollow" target="_blank" href=<?php echo $steamlink; ?> class="name"> <?php echo $winnername; ?> </a>
</div>
<div class="right text-right">
<span class="win">
Win: <span>$ <?php echo round($winnercos, 3); ?> </span></span>
<span class="chance">
Chance: <span><?php echo round($winnerpercent, 2); ?>% </span> </span> </div> </div>