Here is a very basic PHP image gallery component. Save the image gallery component below so it can be included where you want an image gallery.
function imageGallery($gallery_path, $gallery_img, $gallery_txt, $alt_txt) {
print("<table border=\"0\" summary=\"image gallery\">");
for($i = 0; $i < sizeof($gallery_img); $i++) {
if (($i % 3) == 0) print("<tr>");
print("<td>\n");
print("<a href=\"".$gallery_path.$gallery_img[$i]."\">\n");
print("<img src=\"".$gallery_path."tmb/".$gallery_img[$i]."\" alt=\"".$alt_txt[$i]."\"/>\n");
print("</a><br /><br />\n");
print("<i>");
print($gallery_txt[$i]);
print("</i><br /><br />\n");
print("</td>\n");
if (($i % 3) == 2) print("</tr>");
}
if ((sizeof($gallery_img) % 3) != 0) print("</tr>");
print("</table>");
}
When the component has been saved it can be used something like this :
include("../some/path/to/image-gallery.php");
$gallery_img = array();
$gallery_txt = array();
$gallery_alt = array();
$gallery_path = "../some/path/to/images/";
$gallery_img[0] = "img1.JPG";
$gallery_txt[0] = "Image 1 caption";
$gallery_alt[0] = "Image 1 alt tag";
$gallery_img[1] = "img2.JPG";
$gallery_txt[1] = "Image 2 caption";
$gallery_alt[1] = "Image 3 alt tag";
$gallery_img[2] = "img3.JPG";
$gallery_txt[2] = "Surprise, surprise this is where the caption to image 3 goes";
$gallery_alt[2] = "and this is where alt tag 3 goes.";
imageGallery($gallery_path, $gallery_img, $gallery_txt, $gallery_alt);