Really Stuck


#1

Hi,

I hope someone can help me, been at this for awhile and need to be pointed in the right direction. I’m making a search engine. right now, my results page displays the number of pages of results that have been found. If the number of pages exceeds 20, My content a design gets all messed up. I need to limit the number of pages to about 10. So I want it to look something like this

Previous << 1 2 3 4 5 6 7 8 9 >> Next

When I get to 10 I want it to display 10 11 12 13 14 15 16 17 18 19

Obviously this needs to stop at the maximum number of pages found.
Here’s some of my code

//Total Pages
echo “Select a Page”;
echo " - Last Page >> <a href="".$_SERVER[‘PHP_SELF’]."?page=$total_pages" class=‘results’>".$total_pages." 
";

//Previous Link
if($page > 1)
{$prev = ($page - 1);
echo “<a href=”".$_SERVER[‘PHP_SELF’]."?page=$prev" class=‘results’><< Previous ";}

$maximum = 10;
$difference = $total_pages - $maximum;

for($i = $page;
$i <= $maximum;
$i++
)

{if(($page) == $i)
{echo “”;
echo “$i”;
echo “&nbsp”;}
else
{echo “<a href=”".$_SERVER[‘PHP_SELF’]."?page=$i" class=‘results’>$i ";}}

// Next Link
if($page < $total_pages)
{$next = ($page + 1);
echo “<a href=”".$_SERVER[‘PHP_SELF’]."?page=$next" class=‘results’>Next>>
";}
echo “
”;
}


#2

Finally I got this working. This thread can be closed


#3

How about replying with the solution you found so that others will know.

Thanks,