所以我有一个基本的php页面,它调用另一个包含我的mysql查询和输出的php页面。很简单。我使用下面的jquery刷新语句来自动刷新查询所在的div:
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#records').load('user_records.php').fadeIn("slow");
}, 30000); // refresh every 30 seconds
</script>
这是我的user_records.php文件:
<?php
$username = $_GET['user'];
include('connect.php');
$did = array();
$sql = "SELECT * FROM users WHERE username = '$username'";
$result = mysqli_query($link, $sql, MYSQLI_STORE_RESULT);
while($row = $result->fetch_assoc()){
$user_id = $row['id'];
}
$sql = "SELECT * FROM assign_did WHERE user_id = '$user_id'";
$result = mysqli_query($link, $sql, MYSQLI_STORE_RESULT);
while($row = $result->fetch_assoc()){
$did_id = $row['did_id'];
$sql1 = "SELECT did FROM did WHERE id = '$did_id'";
$result1 = mysqli_query($link, $sql1, MYSQLI_STORE_RESULT);
while($row1 = $result1->fetch_row()){
$did[] = $row1[0];
}
}
$did_arr = array();
foreach($did as $newdid){
$did_arr[] = '`extension` LIKE \'%'.$newdid.'\'';
}
echo "<div id='records'><h1 align='center'>Today's Transfers</h1>
<table cellspacing='0' cellpadding='0'>
<tr>
<th> Customer Name</th><th>Phone Number</th><th>Disposition</th><th>DID</th><th>Date Called</th>
</tr>
";
$sql3 = 'SELECT * FROM `vicidial_did_log` WHERE ('.implode(" OR ", $did_arr) . ')';
$result3 = mysqli_query($link, $sql3, MYSQLI_STORE_RESULT);
while($row3 = $result3->fetch_assoc()){
$caller_id_number = $row3['caller_id_number'];
$extension = $row3['extension'];
...echo the rows into rows and columns...
?>
所以它刷新了user_records.php,它有一个id为'records'的div。该div执行mysql查询和回声是。我的问题是,当它刷新时,查询只是空白。它会刷新div,因为在查询开始和开始输出之前,我有一些回显/输出的东西。不知道我在这里做错了什么或者你需要看什么代码。我希望有人能帮帮忙。谢谢。