i am using jquery ajax pagination code, i need some changes.
我正在使用jquery ajax分页代码,我需要一些更改。
<?php
$per_page = 4;
$sql = "select * from portfolio ";
$rsd = mysql_query($sql);
$count = mysql_num_rows($rsd);
$pages = ceil($count/$per_page)
?>
the above code calculates the number of pages then
上面的代码然后计算页数
<?php
//Show page links
for($i=1; $i<=$pages; $i++)
{
echo '<li class="pagenum" id="'.$i.'">'.$i.'</li>';
}
?>
this code display pagination button that is basically
这段代码基本上显示了分页按钮
<li class="pagenum" id="'.$i.'">'.$i.'</li>
all the problem is here with $i .
所有的问题都在这里与$ i。
if $per_page=4 then 7 pagination button appears .
如果$ per_page = 4则会出现7个分页按钮。
pagination occur on basis of
分页发生在...的基础上
id="'.$i.'"
this way
$("#paging_button li").click(function(){
//show the loading bar
showLoader();
$("#paging_button li").css({'background-color' : ''});
$(this).css({'background-color' : '#ccc'});
$("#contentt").load("data.php?page=" + this.id, hideLoader);
});
what i want is to display only next and previous button . instead of seven pagination buttons .
我想要的是只显示下一个和上一个按钮。而不是七个分页按钮。
need to change to logic/code .
需要改为逻辑/代码。
please help
thanks
2 个解决方案
#1
0
var pager = $('<div id="pager" class="pagination"></div>');
// adds the controls of pagination
pager.pagination(maxentries, {
items_per_page : limit,
next_text : '>',
prev_text : '<',
num_display_entries : 5,
load_first_page : false,
callback : callback
});
#2
0
you missed a ;
at the end of this line $pages = ceil($count/$per_page)
.So it needs to be $pages = ceil($count/$per_page);
你错过了;在这一行的末尾$ pages = ceil($ count / $ per_page)。所以它需要是$ pages = ceil($ count / $ per_page);
#1
0
var pager = $('<div id="pager" class="pagination"></div>');
// adds the controls of pagination
pager.pagination(maxentries, {
items_per_page : limit,
next_text : '>',
prev_text : '<',
num_display_entries : 5,
load_first_page : false,
callback : callback
});
#2
0
you missed a ;
at the end of this line $pages = ceil($count/$per_page)
.So it needs to be $pages = ceil($count/$per_page);
你错过了;在这一行的末尾$ pages = ceil($ count / $ per_page)。所以它需要是$ pages = ceil($ count / $ per_page);