Jump to content

photogallary check for error


hamza

Recommended Posts

Please check my gallary and increase the number of

images in the directory

and see in the one of the row there is one image is

missing please locate the error

and remove it tell me as well.

 

00000000000000000000000000000000000000

 

Any suggestion on it?

how to improve it more?

 

00000000000000000000000000000000000000

 

 

 

 

 

To do

make a folde and asisgnt to variable $dirname.

 

=====================================

code is below

<?php 

//calculate total pages.

$totalImages = 0;

$i=0;                    //images names counting

$imgNumber=0;            //used to show the img name in cols 1 and 2.

$imgsNames = array();    //to store the names of the images.

$ImagesStorageArray = array(); //all the images store in a array by using this array.

$dirname = ''; //directory in which images are located.

$dh =  opendir($dirname);

while ( ! is_bool( $file = readdir( $dh )) ) {

  $dir = ( is_dir($file) ) ?  $dir = 'true' : $dir = 'false';                       

        if($dir=='true') { }else{ if( $file=='Thumbs.db'){ continue;} $ImagesStorageArray[] = $file ;  $totalImages++;}       

}//end while

 

 

echo 'Total Images ::  '.$totalImages.'<br>';

 

 

    // number of images in folder.

    $total_items = $totalImages;

   

    //images perpage

    $perPage = 8;

   

    //current page number

    $pageNum = ($_GET[pageNum]=='')? 1 : $_GET[pageNum];    #set default page number.

    $cur = ceil(  $per_page/ $pageNum) + 1;  // Current page number

   

    //start position(key) in the array

    $start = ($_GET[start]=='')?  0        : $_GET[start] - $perPage;   

    //end position(key) in the array

    $end  = ($_GET[start]=='')?  $perPage : $_GET[start];

   

    echo '<table border=1>';

 

        $startval = ($_GET[start]=='')? 0 :  $start;   

        for( $record=$startval;  $record <= $end ;$record++) {

       

            /******* SHOWING THE IMAGES IN TABLES ************/

            if ( empty($firstCol) ) { //IF 'FIRST COLUMN' IS EMPTY THEN SHOW IT

                    //1st COL                                           

                $imgsNames[$i] = $ImagesStorageArray[$record];                                                                           

                ?>          <tr>     

                            <td align=center>

                            <a href="<?php echo $dirname."/".$ImagesStorageArray[$record]; ?>" target="_blank">

                                <img src=<?php echo $dirname ?>/<?php echo $ImagesStorageArray[$record]?> width=100 height=100 border=0>

                            </a>

                            </td>                         

                            <?php $firstCol = 1;  ?>           

                            <?php $i++; ?>                           

                            <?php   

                            $imgNumber++;                                       

                            if( $perPage==$imgNumber) {

 

                                    $k = ( $j=='' )? $j=0 :    $j=$j;

                                    for ($j=$k; $j <= $perPage;) {                                           

                            ?>

                                    <tr>

                                      <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                                      <?php $j++; ?>

                                      <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                                    <?php  $j++; ?>

                                      <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                                    </tr>

                                    <?php  $j++;

                                    break;                                   

                                    }//for end                                                                   

                            }//if end

                       

                       

            } else if( !empty($firstCol) && empty($secondCol) ) { //IF FIRST COLUM IS NOT EMPTY THEN SHOW ' SECOND COLUMN '

                            //2nd COL                                           

                            //storing names in array

                            $imgsNames[$i] = $ImagesStorageArray[$record];?>                                       

                            <td align=center>

                            <a href="<?php echo $dirname."/".$ImagesStorageArray[$record]; ?>" target="_blank">

                                <img src=<?php echo $dirname ?>/<?php echo $ImagesStorageArray[$record]?> width=100 height=100 border=0>

                            </a>

                            </td>                                               

                            <?php $secondCol = "1"; ?>

                            <?php $i++; ?>           

                            <?php

                            $imgNumber++;

                            //SHOWING IMAGES WHEN COUNT ENDS

                            if( $perPage==$imgNumber) {

 

                                        $k = ( $j=='' )? $j=0 :    $j=$j;

                                        for ($j=$k; $j <= $perPage;) {                                           

                                ?>

                                        <tr>

                                          <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                                          <?php $j++; ?>

                                          <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                                        <?php  $j++; ?>

                                          <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                                        </tr>

                                        <?php  $j++;

                                        break;                                   

                                        }//for end                                                                   

                                }//if end

                                                                       

                ?>                           

        <?php } elseif( !empty($firstCol) && !empty($secondCol) ) {//IF BOTH COLUM ARE NOT EMPTY THEN SHOW THIRD

                            //3rd COL                                                                                                                   

                            //storing names in array

 

                            $imgsNames[$i] = $ImagesStorageArray[$record];                                           

                ?>        <?php $cell = 3; ?>

                        <td align=center>

                            <a href="<?php echo $dirname."/".$ImagesStorageArray[$record]; ?>" target="_blank">

                                <img src=<?php echo $dirname ?>/<?php echo $ImagesStorageArray[$record]?> width=100 height=100 border=0>

                            </a>

                        </td>                   

                        </tr>           

                        <?php $i++; ?>

                        <?php                   

                            //MAKE EMPTY BOTH COULMN

                            $firstCol  = '';

                            $secondCol = '';

                        ?>       

                          <?php $imgNumber++;    ?> 

                        <?php //showing images names                                               

                            $k = ( $j=='' )? $j=0 :    $j=$j;

                            for ($j=$k; $j <= $perPage;) {                                           

                        ?>

                            <tr>

                              <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                              <?php $j++; ?>

                              <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                            <?php  $j++; ?>

                              <td align="center"><?php echo $imgsNames[$j]; ?> </td>

                            </tr>

                            <?php  $j++; ?>

                            <?   

                            break;                                   

                            }//for end. ?>                                       

                           

              <?php         

        }//if end       

    }//for end       

echo '</table>';       

 

$maxPages = ceil($total_items/$perPage);   

$self = $_SERVER['PHP_SELF'];

$nav = '';

for($page = 1; $page <= $maxPages; $page++)

{

 

    $start = ceil(  $perPage * $page );

 

    if ($page == $pageNum)

    {

        $nav = $nav." $page ";  // no need to create a link to current page

    }

    else

    {

        $nav = $nav." <a href=\"$self?pageNum=$page&start=$start\">$page</a> ";

    }

}

 

echo '<br>';

echo $nav;

?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>photogallarywork</title>

</head>

 

<body>

</body>

</html>

 

 

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.