SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    limiting the amount to display

    Ok I have a script that reads a dir and displays all the images in the dir,

    the problem is i only want to display 10 per page,

    I van limit it by using a break function but how do i start to read from the second 10??

    Does anyone know how to do this???

    I have inserted the code below for your review.

    PHP Code:
    <?php

    $handle
    =opendir('./'.$dir) or die();
    $pics=array();
    while ((
    $file readdir($handle))!==false) {
            if (
    substr($file,-4) == ".jpg" || substr($file,-4) == ".gif" || substr($file,-4) == ".png"){
              
    $pics[$count] = $file;
             echo
    "<image src=\"".$dir."/".$pics[$count]."\" alt=\"".$pics[$count]."\"><br>";
             echo 
    $pics[$count]."<br>";

         }
    }
    echo 
    "there are ".$count." Pics";
    closedir($handle);


    ?>
    Thanks

    K-
    Last edited by The Mog; Dec 27, 2002 at 17:39.

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put the string returned from serialize($pics) in one hidden field and the current first index in another hidden field
    Post the form to the same page, unserialize the file names, get the index, add/subtract 10 (depending on which button was clicked; next/previous), and display 10 files from the array


Bookmarks

Posting Permissions

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