Trying to build a dynamic gallery that is loaded via AJAX.
I'm trying to get it to build a ul with as many list items as there are pictures, because each gallery has a different amount of images... something like this:
<ul id="foo">
<li><a href="javascript:void(0);"><img src="../images/portfolio/foo/001.jpg></a></li>
<li><a href="javascript:void(0);"><img src="../images/portfolio/foo/002.jpg></a></li>
</ul>
<div class="description">FOO TITLE / DESCRIPTION</div>
<ul id="bar">
<li><a href="javascript:void(0);"><img src="../images/portfolio/bar/001.jpg></a></li>
<li><a href="javascript:void(0);"><img src="../images/portfolio/bar/002.jpg></a></li>
<li><a href="javascript:void(0);"><img src="../images/portfolio/bar/003.jpg></a></li>
</ul>
<div class="description">BAR TITLE / DESCRIPTION</div>
I'm not familiar enough with PHP to build in the foreach to the function I've built. Any help? Here is what I have so far (note the array I have is a temporary solution... it doesn't work if the project has less/more than the 4 that I've listed in the array):
<?php function generateProject($projTitle,$projDesc) {
$proj = $_GET['proj'];
echo '<ul id="'.$proj.'">';
$array = array('001','002','003','004');
foreach($array as $picture)
{
echo '<li><a href="javascript:void(0);"><img src="../images/portfolio/'.$proj.'/'.$picture.'.jpg"';
echo '</li>';
}
echo '</ul>';
echo '<div class="description">'.$projTitle.' <span class="slash"> / </span>'.$projDesc.'</div>';
} ?>
<?php
generateProject(
'deadAWESOME',
'Gargoyles. Dusty leather tomes. Hidden rooms. Coffee.');
?>
generateProject. I don't know how I'm obtaining the list. If I could just put "6" and then it automatically pulls 001, 002, ... 006, that would work. If it recurses and finds them, that works, too.