Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post

    Post Pagination problem with listing directory result

    Good day to you all,
    can somebody help me with my pagination, the following code does not give me any error but the pagination part of the script don't do his job.






    PHP Code:
    <?php




            
    // Images directory lister start script
    $image_counter = -1;
    $row_counter 0;
    $cell_counter 0;
    $show=array('.jpg','.JPG','.gif','.GIF');
    $path 'Images/2/';


    $dir_handle = @opendir($path) or die("Unable to open $path");

    $image_table "<table valign=\"top\" align=\"center\">\n<tr><th colspan=3>Existing Pics in Directory:</th></tr>\n<tr>";
    while (
    false !== ($file readdir($dir_handle))) {
      if(
    in_array(substr($file,-4,4),$show)){
            if(!((
    $image_counter 1) % 3)){
              
    $row_counter++;
            }
    $newpath0 basename($file,".*");
          
    $image_table .=(($image_counter 1) % 3)? "" "</tr>\n<tr><td><br></td></tr><tr valign=\"top\">";
          
    $image_table .= "\n<td valign=\"top\"><table width=\"200\" border=\"1\" cellpadding=\"0\" cellspacing=\"1\" align=\"center\">\n";
          
    $image_table .= "\n<tr><td align=\"center\"><b>$newpath0</b></td></tr>\n";
          
    $image_table .= "\n<td><img src=\"$path$file\" width=\"200\"></td></tr>\n";
          
    $image_table .= "\n<tr><td></td></tr>\n";
          
    $image_table .= "\n<tr><td><b>Prix :</b> Test</td></tr>\n";
          
    $image_table .= "\n<tr><td><b>Prix :</b> Test</td></tr>\n";
          
    $image_table .= "\n<tr><td><b>Prix :</b> Test</td></tr>\n";
          
    $image_table .= "\n</table></td>\n\n\n";

          ++
    $image_counter;
          ++
    $cell_counter;
      }

    }





    $colspan= ($row_counter 3) - $cell_counter;
    $image_table .= ($cell_counter 3) ?  "<td colspan=$colspan>&nbsp;</td>" "";
    $image_table .= "</tr>\n</table>\n";
    echo 
    "$image_table<br><br>";


            
    // Pagination script start
    class display {
        function 
    pagination($rows$per_page$current_page$page_link) {
            global 
    $core,$C;
            
            
    // Create a Page Listing
            
    $this->pages ceil($rows $per_page);
            
            
    // If there's only one page, return now and don't bother
            
    if($this->pages == 1) {
                return;
            }
            
            
    // Pagination Prefix
                    
    $output .= "<!-- Pagination by Dennis Pedrie. Used by Permission -->";
            
    $output "Pages: ";
            
            
    // Should we show the FIRST PAGE link?
            
    if($current_page 2) {
                
    $output .= "<a href=\""$page_link ."?page=1/\" title=\"First Page\"><<</a>";
            }
            
            
    // Should we show the PREVIOUS PAGE link?
            
    if($current_page 1) {
                
    $previous_page $current_page 1;
                
    $output .= " <a href=\""$page_link .">page="$previous_page ."/\" title=\"Previous Page\"><</a>";
            }
            
            
    // Current Page Number
            
    $output .= "<strong>[ "$current_page ." ]</strong>";
            
            
    // Should we show the NEXT PAGE link?
            
    if($current_page $this->pages) {
                
    $next_page $current_page 1;
                
    $output .= "<a href=\""$page_link ."?page="$next_page ."/\" title=\"Next Page\">></a>";
            }
            
            
    // Should we show the LAST PAGE link?
            
    if($current_page $this->pages 1) {
                
    $output .= " <a href=\""$page_link ."?page="$this->pages ."/\" title=\"Last Page\">>></a>";
            }
            
            
    // Return the output.
            
    return $output;
        }
    }

    $display = new display;
    echo 
    $display->pagination($row_counter"2""1""http://theponther.peuplies.info/AAA%20TEST/Images/images3.php");

    echo 
    "<br>";
    echo 
    "<b>Total Cells w pics: $cell_counter<br>";
    echo 
    "<b>Total Rows: $row_counter<br>";
    echo 
    "<b>Empty Cells in last row: $colspan";
    ?>


    Thanks !

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Try using Firepage's pagination script. You can have it up and working in about 10 minutes.

    www.firepages.com.au

  • #3
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post
    thanks but I can't use db.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I adapted the Firepage script to page through icon files in a directory-- no database involved.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •