请朋友们我想运行一个javascript代码来加载一个基于$ _GET变量的php页面。这是实际的页面:
<?php
$online = mysqli_query($con, "SELECT * FROM (SELECT user as user FROM online) as a INNER JOIN
(SELECT one as f1 FROM friends WHERE two='$my_id'
UNION SELECT two as f2 FROM friends WHERE one='$my_id') as b
ON a.user = b.f1");
while($query = mysqli_fetch_array($online)){
$active = $query['user'];
$first = getuser($active, 'first');
$nick = getuser($active, 'nick');
$last = getuser($active, 'last');
?>
<?php
echo "<font class='driver'>$first $nick $last</font>";
<div style="width:100%;height:82%;overflow-x:no;overflow-y:auto;" id="show">
<script type="text/javascript" src="jscript.js"></script>
<script type="text/javascript">
$(document).ready(function() {
setInterval(function () {
$('#show').load('active_chat.php')
}, 2000);
});
</script>
</div>
因此我希望此行$('#show').load('active_chat.php')
看起来像这样$('#show').load('active_chat.php?id=$active')
,以便它只显示每个$active
用户输入的信息,这里是active_chat.php; < / p>
<?php
include 'connect.php';
include 'functions.php';
$my_id = $_SESSION['user_id'];
$user = $_GET['id'];
$query = mysqli_query($con, "SELECT * FROM all_msgs WHERE (my_id='$my_id' AND user_id='$user') OR (my_id='$user' AND user_id='$my_id') AND delet !='$my_id' ORDER BY id DESC");
while($sql = mysqli_fetch_array($query)){
$msg = $sql['msg_body'];
$sender = $sql['my_id'];
$first = getuser($sender, 'first');
$nick = getuser($sender, 'nick');
$last = getuser($sender, 'last');
$photo = getuser($sender, 'photo');
echo $first." ".$nick." ".$last;
} ?>