Created
March 14, 2011 01:25
-
-
Save avinash2/868631 to your computer and use it in GitHub Desktop.
A basic PHP Gallery function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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