to display my pages I used
<ul id="pagination">
Code: Select all
for($i=1; $i<=$pages; $i++)
{
echo '<li id="'.$i.'">'.$i.'</li>';
}Where $i is the page number
There is an obvious problem, that is that every page is listed which is more that the user wants to see. I would like to limit the results to 4 results on each side of the page number you are on. I have tried $i<=$i+4 as a condition to limit one side of the results but that did not work. Anyone have an idea on how to approach this? Can php solve this or is this a javascript problem?
This is the javascript to give you an idea of how it works
Code: Select all
$(document).ready(function(){
//Display Loading Image
function Display_Load()
{
$("#loading").fadeIn(900,0);
$("#loading").html("<img src='pagination/bigLoader.gif' />");
}
//Hide Loading Image
function Hide_Load()
{
$("#loading").fadeOut('slow');
};
//Default Starting Page Results
$("#pagination li:first").css({'color' : '#FF0084'}).css({'border' : 'none'});
Display_Load();
$("#content").load("pagination/pagination_data.php?page=1", Hide_Load());
//Pagination Click
$("#pagination li").click(function(){
Display_Load();
//CSS Styles
$("#pagination li")
.css({'border' : 'solid #dddddd 1px'})
.css({'color' : '#0063DC'});
$(this)
.css({'color' : '#FF0084'})
.css({'border' : 'none'});
//Loading Data
var pageNum = this.id;
$("#content").load("pagination/pagination_data.php?page=" + pageNum, Hide_Load());
});
});