+ Reply to Thread
Results 1 to 2 of 2
Like Tree2Likes
  • 1 Post By mlowe.space12
  • 1 Post By bdistler

Thread: php pagination problem

  1. #1
    mlowe.space12 is offline x10Hosting Member mlowe.space12 is an unknown quantity at this point
    Join Date
    Oct 2010
    Posts
    4

    Question php pagination problem

    I got this pagination thing from this forum but there are a few errors. it comes up with First | Last | Last | Last | Last | Last | and i need it to display in 2 columns
    here is the code:

    PHP Code:
    PHP Code:
    <?php 
    if(!$_GET['start']) { 
    $start 0
    } else { 
    $start $_GET['start']; 

    $exclude_files = array(""); 
    $ifiles = Array(); 
    $handle opendir('upload/'); 
    $number_to_display '10'
    while (
    false !== ($file readdir($handle))) { 
       if (
    $file != "." && $file != ".." && !in_array($file$exclude_files)) {     
           
    $ifiles[] = $file
       } 

    closedir($handle); 

    $total_files count($ifiles); 
    $req_pages ceil($total_files/$number_to_display); 

    echo 
    "Total Images = "$total_files."<br>"


       for(
    $z=0$z<$number_to_display$z++) { 
          
    $vf $z+$start
           
    $ifiles_display explode("."$ifiles[$vf]); 
          echo 
    "<img width=200 height=200 src =upload/" $ifiles[$vf]. "></img>"
      echo 
    '<br>'


    echo 
    "<a href=\"?start=0\">First</a> |"
       for(
    $x=1$x<$req_pages$x++) { ?> 
    <a href="?start=<?php echo ($x)*$number_to_display?>">Last</a> | 

    <?php ?>
    dinomirt96 likes this.

  2. #2
    bdistler's Avatar
    bdistler is offline x10 Lieutenant bdistler is an unknown quantity at this point
    Join Date
    May 2010
    Location
    Catalina AZ USA
    Posts
    349

    Re: php pagination problem

    Be sure the files are 'img' type
    set $workDir
    This displays in one column
    use HTML and CSS for more columms

    PHP Code:
    <?php
    // program => test_pagination.php <=

    $exclude_files = array("");
    $ifiles = Array();
    $number_to_display '10';
    $workDir 'test';

    if(!
    $_GET['start'])
      {
        
    $start 0;
      }
      else
        {
          
    $start $_GET['start'];
        }

    $handle opendir($workDir);

    while (
    FALSE !== ($file readdir($handle)))
      {
       if (
    $file != "." && $file != ".." && !in_array($file$exclude_files))
        {
          
    // replace space in file name with "%20" else 'src = ' will stop at first
          // space for file name
          
    $file str_ireplace(" ""%20"$file);

          
    $ifiles[] = $file;
        }
      }

    closedir($handle);

    $total_files count($ifiles);
    $req_pages ceil($total_files/$number_to_display);

    print 
    "Total files = "$total_files."<br>\n";
    print 
    "$req_pages pages at $number_to_display max per page<br>\n";
    print 
    "Start at #" . ($start 1) . "<br>\n";

    $temp $start $number_to_display;

    if (
    $temp $total_files)
      {
        
    $next_number_to_display $total_files $start;
      }
      else
        {
          
    $next_number_to_display $number_to_display;
        }

    print 
    "Number to show = " $next_number_to_display "<br>\n";

    for(
    $z=0$z<$next_number_to_display$z++)
      {
        
    $vf $z+$start;
        print 
    "<img width=100 height=100 src = $workDir/$ifiles[$vf]>" . ($vf 1) . "</img><br>\n<br>\n";
      }

    print 
    "<a href=\"?start=0\">First start 1</a> | \n";

    for(
    $x=1$x $req_pages 1$x++)
      {
        
    $temp $x $number_to_display;
        print 
    "<a href=\"?start=$temp\">Next $number_to_display start at " . ($temp 1) . "</a> | \n";
      }

    $temp $temp $number_to_display;
    $y $total_files - ($x $number_to_display);

    print 
    "<a href=\"?start=$temp\">Last $y start at " . ($temp 1) . "</a>";

    ?>
    karimirt47 likes this.

+ Reply to Thread

Similar Threads

  1. Replies: 3
    Last Post: 07-08-2010, 01:47 AM
  2. PHP Pagination
    By diabolo in forum Programming Help
    Replies: 6
    Last Post: 06-17-2010, 10:55 AM
  3. PHP Pagination, can someone help please?
    By chibib0 in forum Programming Help
    Replies: 2
    Last Post: 05-03-2008, 09:29 AM
  4. Problem uploading image (GD library problem)
    By HyDr@ in forum Free Hosting
    Replies: 1
    Last Post: 12-01-2006, 04:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers