justplaindoug
06-29-2007, 12:17 AM
I am not sure how to search for this exact answer- so forgive me if this is old hat.
I am pulling info from my database (mysql using PHP) and that is working fine. But it shows a metric ton of pages (every page available) taking up a lot of space on a page.
i.e. There are[1457] Listings in the Database Results 1 - 8 of 1457 Page 1 of 183
1 2 3 4 5 6 7 8 9 10 11 (the rest omited so I don't get death threats) 178 179 180 181 182 183 next
I am trying to find out how to limit the numbers shown so that I get a result more closely resembling something like
1 2 3 >> 183 183 or something like that. Anything that doesn't list each page.
Here is the code that shows that particular section
<? if($numberOfRows>8){
if ($page != 0) { // Don't show back link if current page is first page.
$back_page = $page - $limit;
echo("<a href=\"index.php?query=$query&page=$back_page&limit=$limit&artistselect=$Imagemain2\">back</a> \n");}
for ($m=1; $m <= $pages; $m++) // loop through each page and give link to it.
{
$ppage = $limit*($m - 1);
if ($ppage == $page){
echo("<b>$m</b>\n");} // If current page don't give link, just text.
else{
echo("<a href=\"index.php?query=$query&page=$ppage&limit=$limit&artistselect=$Imagemain2\">$m</a> \n");}
}
if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link.
$next_page = $page + $limit;
echo(" <a href=\"index.php?query=$query&page=$next_page&limit=$limit&artistselect=$Imagemain2\">next</a>");}}
?>
If you require any other info or code from the page let me know- but I would really appreciate any help.
TIA
Doug
I am pulling info from my database (mysql using PHP) and that is working fine. But it shows a metric ton of pages (every page available) taking up a lot of space on a page.
i.e. There are[1457] Listings in the Database Results 1 - 8 of 1457 Page 1 of 183
1 2 3 4 5 6 7 8 9 10 11 (the rest omited so I don't get death threats) 178 179 180 181 182 183 next
I am trying to find out how to limit the numbers shown so that I get a result more closely resembling something like
1 2 3 >> 183 183 or something like that. Anything that doesn't list each page.
Here is the code that shows that particular section
<? if($numberOfRows>8){
if ($page != 0) { // Don't show back link if current page is first page.
$back_page = $page - $limit;
echo("<a href=\"index.php?query=$query&page=$back_page&limit=$limit&artistselect=$Imagemain2\">back</a> \n");}
for ($m=1; $m <= $pages; $m++) // loop through each page and give link to it.
{
$ppage = $limit*($m - 1);
if ($ppage == $page){
echo("<b>$m</b>\n");} // If current page don't give link, just text.
else{
echo("<a href=\"index.php?query=$query&page=$ppage&limit=$limit&artistselect=$Imagemain2\">$m</a> \n");}
}
if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link.
$next_page = $page + $limit;
echo(" <a href=\"index.php?query=$query&page=$next_page&limit=$limit&artistselect=$Imagemain2\">next</a>");}}
?>
If you require any other info or code from the page let me know- but I would really appreciate any help.
TIA
Doug