Forum Moderators: coopster

Message Too Old, No Replies

array element printing control

         

kumarsena

3:36 pm on Nov 9, 2003 (gmt 0)

10+ Year Member



hey,

i nned to know how to print elements in an array and tehn stop printing after a certain number, say 12. then by clicking on a link i want to printing to continue or start somewhere else in the array, but agian only print only 12 elements. i just need to know the theory behind and any function si may need. it is for a photo gallery where i want ot controll the number of thumbs per page.

thanks for any help

kumar

kumarsena

3:37 pm on Nov 9, 2003 (gmt 0)

10+ Year Member



sorry about the spelling...:)

dcrombie

6:29 pm on Nov 9, 2003 (gmt 0)



All you need is a for loop and a variable telling the page which image to start on:

<?PHP
$NUMPERPAGE = 12;
if (!$index) $index = 0;
for ($i=1; $i <= $NUMPERPAGE; $i++) {
echo "<P>Displaying image " . ($index+$i) . "</P>";
}
?>

Then your links can be:

gallery.html
gallery.html?index=12
gallery.html?index=24
...

kumarsena

8:55 am on Nov 11, 2003 (gmt 0)

10+ Year Member



thanks alot, that was easier than i tought. i always have problems with the logic behind a piece of code...

cheers.
kumar