आप mySQL अनुरोध और url जनरेटर में LIMIT सेट करना भूल जाते हैं:
पीएचपी
<?php
$link = mysql_pconnect("localhost", "user", "pass") or die("Could not connect");
mysql_select_db("dbase") or die("Could not select database");
//GET page/count
$count=10;$offset=0;
if (isset($_GET['count'])) $count=$_GET['count']*1;
if (isset($_GET['page'])) $offset=$_GET['page']*$count*1;
$arr = array();
$rs = mysql_query("SELECT * FROM bannersright
ORDER BY HdOrder
LIMIT $offset,$count"); #<-HERE
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
echo '{"bannersright":'.json_encode($arr).'}';
?>
जेएस:
$(function () {
$("#wrapper #sidebar-right").autobrowse(
{
url: function (offset)
{
return "http://www.mysite.com/json.php?count=10&page="
+Math.round(offset/10); // <-- AND HERE
},
template: function (response)
{
var markup='';
for (var i=0; i<response.bannersleft.length; i++)
{
markup+='<a href="'+response.bannersleft[i].URL+'"><img src="'+response.bannersleft[i].Image+'" /></a>'
};
return markup;
},
itemsReturned: function (response) { return response.bannersleft.length; },
offset: 0,
max: 1,
loader: '<div class="loader"></div>',
useCache: false,
expiration: 1
}
);
});