所以基本上我有一个load.php
页面,它接收一个位置变量并使用它从表格中显示该位置的 6 个结果......但我看到某处有一个错误,因为什么都没有返回......你们能帮忙吗?
这是代码:
<?php
error_reporting(0);
session_start();
include '../upload/connect.php';
$start = $_POST['start'];
$id = $_POST['id'];
$sql = mysql_query("SELECT * FROM comments WHERE id='".$id."' ORDER by id DESC LIMIT ".$start." , 6 ") or die(mysql_error());
while ($display = mysql_fetch_assoc($sql))
{
?>
<div id="comments">
<table>
<tr>
<td rowspan="2"><img src="../pic/logo.png" width="100px" /></td>
<td valign="top"><p style="width:700px;font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif;font-size:13px;color:rgba(255,255,255,0.5);"> Postat de <?php echo $display['user']; ?> la <?php echo $display['date']; ?> </p></td></td>
</tr>
<tr>
<td width="90%" valign="top"><p style="width:700px;font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif;font-size:13px;color:white;"> <?php echo $display['comment']; ?></p>
</tr>
</table>
</div>
<?php
}
?>
和jQuery:
var st = 6;// start position...
var div_height = $("#mighty_holder").height()/2- 50;
var doc_scroll = $(document).scrollTop();
function loadthem (k)
{
$.post('../core/load.php',{start: k , id: <?php echo json_encode($id); ?>},
function(result){
$("#comment_holder").append(result);
});
}
$(document).scroll(function(){
if ($("#mighty_holder").height()/2- 50 < $(document).scrollTop())
{
loadthem(st);
st = parseInt(st) + 7;
}
});