Friday, July 6, 2012

Simple Image Gallery php

Simple Image Gallery php

First You need make 2 folders as in this example called "img_gal" and "img_big".img_big is inside the img_gal.Then insert big images to img_big folder and then by using image processing software you can re-size the images to appear as thumbnails and store in img_gal folder.Please remember to keep same name in each images in 2 folders.


 Create following php file to display the above image gallery.

<?php

$images = "img_gal/";
$big    = "img_big/";
$cols   = 3;

if ($handle = opendir($images)) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
           $files[] = $file;
       }
   }
   closedir($handle);
}

$colCtr = 0;

echo '<table width="100%" cellspacing="3"><tr>';

foreach($files as $file)
{
  if($colCtr %$cols == 0)
    echo '</tr><tr><td colspan=3><hr style="color:#c00;background-color:#c00;height:10px;border:none;" /></td></tr><tr>';
  echo '<td align="center"><a href="' . $images . $big . $file . '"><img src="' . $images . $file . '" /></a></td>';
  $colCtr++;
}

echo '</table>' . "\r\n";

?>

25 comments:

  1. With a good understanding of your audience and area of study established, create an outline of course objectives, time lines and reference material. This outline will provide your students a guideline for what they should expect to learn and what you will expect from them. Outlines can be broken down by time periods or by level of completion. Thanks.
    Regards,
    website design company

    ReplyDelete
  2. Good day! This post couldn't be written any better! Reading this post reminds me of my good old room mate! He always kept chatting about this. I will forward this write-up to him. Pretty sure he will have a good read. Thank you for sharing!

    Feel free to visit my site - Louis Vuitton Handbags

    ReplyDelete
  3. Firma seçimi, parça 나주출장샵eşya taşıma hizmeti sunan firmalar arasında doğru tercih yapmanın önemli bir adımıdır

    ReplyDelete