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
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to get 20 images per page?

    hiiii this is my first post ^_^... see i needed help with my gallery script. I found this script online it displays all the thumbs on 1 page, and since my gallerys reach over 300pics i was wondering how i can get this to cut off the thumbs to like 20 per page
    thank you :)



    Code:
    <?
    include("../header.php");
    include("anime.php");
    
    //Variables
    
    $a = '0';
    $filepath = 'images/';
    $url_path = 'images/';
    $dir = dir($filepath);
    //Table Setup
    
    echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"5\" width=\"75%\">";
    
    while($image=$dir->read()) {
    if($image == "." || $image == "..") { 
    continue; 
    } 
    $fp = @fopen("$filepath/$image","r");
    
    //Table Return
    if ($a == '0') {echo "<tr>";}if ($a == '5') {echo "<tr>";}
    if ($a == '10') {echo "<tr>";}if ($a == '15') {echo "<tr>";}
    if ($a == '20') {echo "<tr>";}if ($a == '25') {echo "<tr>";}
    if ($a == '30') {echo "<tr>";}if ($a == '35') {echo "<tr>";}
    if ($a == '40') {echo "<tr>";}if ($a == '45') {echo "<tr>";}
    if ($a == '50') {echo "<tr>";}if ($a == '55') {echo "<tr>";}
    if ($a == '60') {echo "<tr>";}if ($a == '65') {echo "<tr>";}
    if ($a == '70') {echo "<tr>";}if ($a == '75') {echo "<tr>";}
    if ($a == '80') {echo "<tr>";}if ($a == '85') {echo "<tr>";}
    if ($a == '90') {echo "<tr>";}if ($a == '95') {echo "<tr>";}
    if ($a == '100') {echo "<tr>";}if ($a == '105') {echo "<tr>";}
    if ($a == '110') {echo "<tr>";}if ($a == '115') {echo "<tr>";}
    if ($a == '120') {echo "<tr>";}if ($a == '125') {echo "<tr>";}
    if ($a == '130') {echo "<tr>";}if ($a == '135') {echo "<tr>";}
    if ($a == '140') {echo "<tr>";}if ($a == '145') {echo "<tr>";}
    if ($a == '150') {echo "<tr>";}if ($a == '155') {echo "<tr>";}
    if ($a == '160') {echo "<tr>";}if ($a == '165') {echo "<tr>";}
    if ($a == '170') {echo "<tr>";}if ($a == '175') {echo "<tr>";}
    if ($a == '180') {echo "<tr>";}if ($a == '185') {echo "<tr>";}
    if ($a == '190') {echo "<tr>";}if ($a == '195') {echo "<tr>";}
    if ($a == '200') {echo "<tr>";}if ($a == '205') {echo "<tr>";}
    if ($a == '210') {echo "<tr>";}if ($a == '215') {echo "<tr>";}
    if ($a == '220') {echo "<tr>";}if ($a == '225') {echo "<tr>";}
    if ($a == '230') {echo "<tr>";}if ($a == '235') {echo "<tr>";}
    if ($a == '240') {echo "<tr>";}if ($a == '245') {echo "<tr>";}
    if ($a == '250') {echo "<tr>";}if ($a == '255') {echo "<tr>";}
    if ($a == '260') {echo "<tr>";}if ($a == '265') {echo "<tr>";}
    if ($a == '270') {echo "<tr>";}if ($a == '275') {echo "<tr>";}
    if ($a == '280') {echo "<tr>";}if ($a == '285') {echo "<tr>";}
    if ($a == '290') {echo "<tr>";}if ($a == '295') {echo "<tr>";}
    if ($a == '300') {echo "<tr>";}if ($a == '305') {echo "<tr>";}
    if ($a == '310') {echo "<tr>";}if ($a == '315') {echo "<tr>";}
    if ($a == '320') {echo "<tr>";}if ($a == '325') {echo "<tr>";}
    if ($a == '330') {echo "<tr>";}if ($a == '335') {echo "<tr>";}
    if ($a == '340') {echo "<tr>";}if ($a == '345') {echo "<tr>";}
    if ($a == '350') {echo "<tr>";}if ($a == '355') {echo "<tr>";}
    if ($a == '360') {echo "<tr>";}if ($a == '365') {echo "<tr>";}
    if ($a == '370') {echo "<tr>";}if ($a == '375') {echo "<tr>";}
    if ($a == '380') {echo "<tr>";}if ($a == '385') {echo "<tr>";}
    if ($a == '390') {echo "<tr>";}if ($a == '395') {echo "<tr>";}
    if ($a == '400') {echo "<tr>";}
    //Link
    ?>
    <td>
    <a href="<? echo "http://falconxanime.homelinux.com:82/Anime/$anime/$image" ?>"  >
    <img src="<? echo "http://falconxanime.homelinux.com:82/Anime/$anime/tn/$image" ?>" alt="<? echo "$anime-$image"?> " ></a>
    </td>
    <?
    $a = $a + 1;
    }
    ?>
    <br>
    <?
    include("../footer.php");
    ?>

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    well let's see, here a rough hack way to do that...

    1. at top of page check to see if anything is in the $_Post array
    2. if empty do steps 3, 4 and 5, else skip to step 6
    3. put all your pics/thumbs into an array
    4. create a table to display the first 20
    5. at the end of the table put a form that has (a) a hidden field name = count = 20; (B) a hidden field containing the array; and (c) posts back to the same page
    6. display the next 20, increment your count for each pic/thumb displayed
    8 . post back to the same page with the new count value

    Lite...

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    somthing like this
    PHP Code:
     <?php
    include("../header.php");
    include(
    "anime.php");
    //Variables
    $images=20;
    $a=0;
    $filepath 'images/';
    $url_path 'images/';
    $dir dir($filepath);
    //grab start
    if(isset($_GET['next']) && is_numeric($_GET['next']))
        { 
          
    $start=$_GET['next']; 
        } 
    elseif(isset(
    $_GET['pre']) && is_numeric($_GET['pre'])) 
        { 
        
    $start=$_GET['pre']; 
    }else{ 
        
    $start=0
        }
    if(
    $start<0){$start=0;}
    $pos=$start
    //Table Setup

    echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"5\" width=\"75%\"><tr>";

    while(
    $image=$dir->read()) {
    if(
    $image == "." || $image == "..") { 
    continue; 

    $imagearray[]=$image;
    }
    //set limits
    $count=count($imagearray);
    if(
    $start>$count-$images)
        {
        
    $start=$count-$images;
        }
    $limit=$start+$images;
    // loop through array from start
    for($i=$start;$i<$limit;$i++)
        {     
    //Table Return

    //Link
    if ($a%5==0) {echo "</tr><tr>";}
    echo
    "<td><a href=\"http://falconxanime.homelinux.com:82/Anime/".$anime."/".$imagearray[$i]."\">";
    echo
    "<img src=\"http://falconxanime.homelinux.com:82/Anime/".$anime."/tn/".$imagearray[$i]."\" alt=\"".$anime."-".$imagearray[$i]."\"></a></td>";
    $a++;
        }
    echo
    "</tr></table>";

    ?>
    <br>
    <?
    //display next previous 
    if($start>0
        { 
        
    $pre=$pos-$images
    echo
    "<a href=\"".$_SERVER['PHP_SELF']."?pre=".$pre."\" >Previous</a> "
        } 
    if(
    $start<$count-$images
        { 
        
    $nex=$pos+$images
        echo
    "<a href=\"".$_SERVER['PHP_SELF']."?next=".$nex."\" >Next</a> "
        } 
    ?>
    Last edited by sidney; 04-29-2004 at 05:52 PM.

  • #4
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Yay-ness

    YAY *bounces around* ty both ^_^ i got it to work >_> now i just have to log into my server and upload it ^_^ and again ty im very new to php


  •  

    Posting Permissions

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