Skip to content

Instantly share code, notes, and snippets.

@avinash2
Created March 14, 2011 01:25
Show Gist options
  • Save avinash2/868631 to your computer and use it in GitHub Desktop.
Save avinash2/868631 to your computer and use it in GitHub Desktop.
A basic PHP Gallery function
<?php
function genGallery($path)
{
$files = scandir("$path");
$pages = array_chunk($files, 12);
$pn = (int) $_GET['page'];
foreach ($pages[$pn] as $file) {
if ($file != "." && $file != "..") {
echo "<a href=\"images/$file\" rel=\"lightbox[group]\" title=\"\">";
echo "<img src=\"images/$file\" alt=\"\" />\n";
echo "</a>\n";
}
}
for ($i = 1; $i < count($pages) + 1; $i++) {
echo "<a href=\"index.php?page=$i\">$i</a>\n";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment