adam291086 Posted December 14, 2007 Share Posted December 14, 2007 Hello, I have a script that opens a directory and displays all the pictures within. How can i limit how many pictures are display and have a next and previou button? Quote Link to comment Share on other sites More sharing options...
peranha Posted December 14, 2007 Share Posted December 14, 2007 Use Pagination http://www.phpfreaks.com/tutorials/43/0.php here is a tutorial Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 14, 2007 Author Share Posted December 14, 2007 only problem with that is that i am not using a database. Quote Link to comment Share on other sites More sharing options...
ManOnScooter Posted December 14, 2007 Share Posted December 14, 2007 steps to be followed 1. Fix the number of pictures to be displayed on each page. $perPage - Hardcode this value into all the code pages 2. Read total number of pictures in an array - find the total number of pictures. $totalPictures 3. use some simple math functions i.e. mod & div to find how many times this iteration would be required 4. Display the number of pictures as per $perPage simple isnt it ? lemme know if you have questions Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 14, 2007 Author Share Posted December 14, 2007 that is very simple. Although i dont use an array. I just run thorough loop This is how i do it <?php $ImageDirectory = "../upload/pictures/thumbnail"; ?> <html> <body> <form action="delete.php" method="post"> <?php $BigImage = "../upload/pictures/picture"; foreach (glob("$ImageDirectory/{*.gif,*.jpg,*.png,*.GIF,*.JPG,*.PNG}", GLOB_BRACE) as $image) { //remove .. for url $dir = str_replace("..", "", "$BigImage"); //get name for url $name = str_replace("$ImageDirectory", "", "$image"); //get name on it's own $fullname = str_replace("/", "", $name); echo '<br />'; echo $fullname; echo '<br />'; echo '<img src="'.$image.'">'; echo '<br />'; echo "www.adamplowman.co.uk".$dir.$name; echo '<br />'; echo "<a href=\"http://www.cycloxchamps.co.uk\admin".$dir.$name."\">View full Image</a>"; echo '<br />'; echo '<input type="radio" name="delete[]" value="'.$image.'" />Delete '.$image; echo '<br />'; echo '<br />'; echo '<input type="submit" value="Delete Selected">'; echo '<br />'; echo '<br />'; } ?> </from> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.