...

View Full Version : php help



kohar
02-23-2010, 02:29 PM
Hello,
I have been working on a website, loading images from database with php. There are previous and next links for additional pages, with a limit of 5 images per page. If there is (for example) 17 images the next link is disabled when the last page is reached. However, if the last page is a multiple of 5, the next link does not get disabled as it should. Here is the link for an example.
http://www.alhebert.us/painting.php
If you notice, the painting page has 25 images, so the next link does not work right on the last page.
If you returned home, then went to art metalwork, there are 6 images, and it disables as it should.




if ($nr < 5)
{
echo " | <font color='CCCCCC'>Next</font><br><br>";
}
else
{
echo " | <a href='painting.php?cps=$cps&lps=$lps'>Next</a><br><br>";
}

print "Images $a - $b of $nr0<br><br>";
//print "$a";
//print "$b";

JAY6390
02-23-2010, 03:01 PM
The way you're doing it is all wrong. You should use the variable that works out the Images 21 - 25 of 25 and check if the upper value of the images being displayed is the same as the total. If it is, don't show the next link (disabled)

kohar
02-23-2010, 05:10 PM
Hi
Thank you so much, This works.



if ($b >= $nr0)
{
echo " | <font color='CCCCCC'>Next</font><br><br>";
}
else
{
echo " | <a href='painting.php?cps=$cps&lps=$lps'>Next</a><br><br>";
}

print "Images $a - $b of $nr0<br><br>";

JAY6390
02-23-2010, 05:12 PM
No problem:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum