i have created auto scroll for my website but i am getting repeated results something like this.if just consider the row no it is giving output like this
100 99 100 99 98 100 99 98 97
here is my javascript and php code first page displays the message from database so i am taking that message id and making one ajax request .here is javascript which is on the same page as first message.
<script>
function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == getDocHeight()) {
$("#imgtag1").html("<img src="http://static.way2enjoy.com/files/loading.gif" /> Loading");
$.post("'.uhome().'/index.php?p=jquery/morethread/'.$nextb.'",
function(data){
$("#imgtag1").before(data);
if (data) {
$("#imgtag1").show();
}
$("#imgtag1").html("");
},"html"
);
}
});
</script>
here is my morethread code
$c=explode("/",$_SERVER[ 'REQUEST_URI' ]); $city1=end($c);
$res = sql_query("select * from tableA where id='{$city1}'");
$row67 = sql_fetch_array($res);
$nextbtn=$row67['id']-1;
echo '<script>
function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == getDocHeight()) {
$("#imgtag1").html("<img src=\"http://static.way2enjoy.com/files/loading.gif\" /> Loading");
$.post("'.uhome().'/index.php?p=jquery/morethread/'.$nextbtn.'",
function(data){
$("#imgtag1").before(data);
if (data) {
$("#imgtag1").show();
}
$("#imgtag1").html("");
},"html"
);
}
});
</script>';
echo '<br></br>';
echo nl2br(decode_bb(h($row67['id'])));
echo '<br></br>';
echo '<b>=============================================</b>';
echo '<br></br>';
echo nl2br(decode_bb(h($row67['message'])));
echo '<br></br>';
echo '<b>=============================================</b>';
echo '<br></br>';
here is my live page where i am doing mistake .
http://way2enjoy.com/forums/viewthread/149498/