Results 1 to 6 of 6

Thread: New: How do I paginate?

  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool New: How do I paginate?

    How can I?
    PHP Code:
    <?php

    $dir 
    "thumbs/"
    echo 
    "<br /><br /><center>";
    //open dir
    if ($opendir opendir($dir))
    {
    //read dir    
    while (($file readdir($opendir)) !== FALSE)
    {
    if (
    $file!="."&&$file!="..")
    echo 
    "<a href='image.php?id=$file'><div id=\"image\"><img src='thumbs/$file'\ ></div></a>&nbsp;&nbsp;&nbsp;&nbsp;";
    }
    }
    echo 
    "</center>";
    ?>
    I need to paginate the images, how can I?
    Last edited by Download; 06-23-2010 at 02:08 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Here's the usual method for this:
    PHP Code:
    $d opendir($d); //open dir
    while ($f readdir($d)) { //get the next file
         
    if ($f=='.'||$f=='..') { continue; } //skip if it's the current or parent directory -- always use this
         
    if (is_dir($d.'/'.$f)) { continue; } //HERE-- skip directories
         
    echo $d.'/'.$f//path to file. Skip $d if you just want the filename

    Add the check to be sure is_dir($d) at the top if you want.


    'continue' makes the loop skip the rest of that instance and go back to the beginning.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    Download (06-23-2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hey, coincidentally my name is Dan also!

    Anyways you weren't fast enough :P
    Thanks anyways, rep +1 for you my good man

  5. #4
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    New topic, can anyone help?

  6. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    What? Why did you edit your post? This is confusing for someone else who might have been helped by the previous information/answers.

    Feel free to start a new thread if you want to ask a new question, though.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #6
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Ok, thanks anyways I have figured this out. If you want you can lock this thread

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
  •