我正在处理消息传递PHP脚本。为了查看用户他们的消息,我正在尝试重新加载DIV,以便我应该是实时的。我有两个页面,其中显示了新消息的数量:
<?php
include ('config.php')
?>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script>
var auto_refresh = setInterval(function () {
$('#xxxx').fadeOut('slow', function() {
$(this).load('message.php', function() {
$(this).fadeIn('slow');
});
});
}, 40000);
</script>
<div id="xxxx"><?php include ('yahu.php') ?></div>
其他页面显示重新加载结果:
<?php
include ('config.php');
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
$nb_new_pm = $nb_new_pm['nb_new_pm'];
if ($nb_new_pm == 0)
{
}
else
{
?>
<font color="black">You have got <?php echo $nb_new_pm; ?> new message(s).</font>
<?php
}
?>
首先,它运作得很好。但是当页面重新加载时它只显示值为
“nb_new_pm”,它也将它的颜色改为白色。
请帮助我!!!!!
答案 0 :(得分:0)
有几件事在这里尖叫。
希望这有助于一点点好运!