Expand|Select|Wrap|Line Numbers
- <?php
- // generating a array with image paths
- $query_images = "SELECT image_path,image_name FROM userfolders" ;
- $result_images = mysql_query($query_images);
- confirm_query($result_images);
- while ($record_images = mysql_fetch_assoc($result_images)) {
- $file = $record_images['image_name'] ;
- $dirname = $record_images['image_path'] ;
- // generating a thumbnail
- $thumb_height = 100;
- $filename = $dirname."/".$file;
- $filename_array[] = $filename ;
- list($width, $height) = getimagesize($filename);
- $ratio = ($height/$width);
- $ratio_array[] = $ratio;
- $newheight = $thumb_height;
- $newheight_array[] = $newheight;
- $newwidth = ($thumb_height/$ratio);
- $newwidth_array[] = $newwidth;
- $page = empty($_GET['page']) ? 1 : $_GET['page'];
- $num_per_page = 4;
- $total_pages = ceil(count($filename_array)/$num_per_page);
- }
- ?>
- <?php
- for($i = ($page - 1) * $num_per_page; $i < $page * $num_per_page; $i++)
- {?><li><a href="<?php echo $filename_array[$i]; ?>">
- <img src="<?php echo $filename_array[$i]; ?>" width="<?php echo $newwidth_array[$i]; ?>" height="<?php echo $thumb_height_array[$i]; ?>" align="top"
- alt="<?php echo $filename_array[$i]; ?>" /></a></li>
- <?php
- }
- ?>
- <?php
- echo "</ul>";
- $pages = array();
- for($i = 1; $i <= $total_pages; $i++) {
- $pages[] = "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a>";
- }
- echo "Page: ".implode(" ", $pages);
- ?>