Dubird 6,815 Report post Posted February 7, 2008 Ok, here's the problem. On my graphics site, I have a TON of different things. I want to be able to display say 5 of them, but on the bottom, I want to generate a page number list (like page 1 2 3 with links). I can't seem to word that question in a way that I can find it through searching, so I thought I'd ask here. I've seen it before and it was pretty easy, but now I can't find it. ; Quote Yesterday was the deadline for all complaints! Share this post Link to post Share on other sites
Mathias 426 Report post Posted February 8, 2008 Ok, here's the problem. On my graphics site, I have a TON of different things. I want to be able to display say 5 of them, but on the bottom, I want to generate a page number list (like page 1 2 3 with links). I can't seem to word that question in a way that I can find it through searching, so I thought I'd ask here. I've seen it before and it was pretty easy, but now I can't find it. ; If the images have links in a database then use the limit option in your SQL. Your links at the bottom of the page pass the page number via a form or links with hard-coded $_GET parameters. select * from `table` where some_condition order by some_variable desc limit page_number*limit, limit select * from `table` where some_condition order by some_variable desc limit 25, 5 Quote Understand this lad, fate is a fickle lady. Work with the hand you're dealt and you may just be able to run your flag up the pole. Don't, and well, you may just find your mast cut down. Share this post Link to post Share on other sites
Dubird 6,815 Report post Posted February 8, 2008 how does that create the page numbers and links to them at the bottom? Quote Yesterday was the deadline for all complaints! Share this post Link to post Share on other sites
Mathias 426 Report post Posted February 9, 2008 Count the number of images via sql query or by reading the directory. Divide the count by the number of images per page. Now that you know how many pages there are, create a link for each page passing the page number selected. Select the number of images from your limit starting at the page number times the limit using the limit sql example, or start a for loop with a starting position of the page number times the limit. Display your images. select count([I]some_variable[/I]) as [I]total_images[/I] from `[I]table[/I]` where [I]some_condition[/I] Use the previous limit sql example to display your images. If you are reading the directory directly then use the readdir function to read each filename into an array. http://us3.php.net/manual/en/function.readdir.php Use the opendir function to allow you to read the directory. for ($i = $page_number * $limit; $i < $page_number * $limit + $limit; $i++) { // Create array of displayed images with the readdir function. } Create the page number links in a list and style with CSS or print one after the other in a <div> or <p>. print "<ol>"; for ($i = 0; $i < $total_images; $i++) { print "<li><a href=\"some_page.php?page_number=" . $i . "\">" . $i . "</a></li>"; } print "</ol>"; Quote Understand this lad, fate is a fickle lady. Work with the hand you're dealt and you may just be able to run your flag up the pole. Don't, and well, you may just find your mast cut down. Share this post Link to post Share on other sites