I am developing a zenphoto gallery for my office to use for employee pictures. One of the features I'd like to add is the ability to show all employee pictures on one page (we have about 250 employees, so it isn't that much of a load). I have implemented the special page, and it shows all the images in all the albums, however, some albums have duplicate images that are also in other albums. How would it be best to structure the query in order to "weed" out the duplicates? I've tried a number of options such as SELECT Distinct, but it won't remove the duplicate entries. Any ideas would be greatly appreciated. I'll be glad to share my final code once it's working in case someone else could make use of it.
Here is my function:
/* Show All Images (Thumbs) */
function show_all_images() {
$iw = $cw = zp_conf('thumb_crop_width');
$ih = $ch = zp_conf('thumb_crop_height');
$sql = "SELECT * FROM ". prefix("images") ." ORDER BY id DESC";
$result = mysql_query($sql);
while($r = mysql_fetch_array($result)) {
$id=$r['albumid'];
$sql="SELECT * FROM ". prefix("albums") ." WHERE id = $id";
$album = mysql_query($sql);
$a = mysql_fetch_array($album);
echo '<div class="image">';
echo '<div class="imagethumb">';
echo '
';
echo '<img src="'.WEBPATH.'/zen/i.php?a='.$a['folder'].'&i='.$r['filename'].'&s=thumb" alt="'.$r['title'].'" />';
// echo '<img src="'.WEBPATH.'/zen/i.php?a='.$a['folder'].'&i='.$r['filename'].'&w='.$iw.'&h='.$ih.'&cw='.$cw.'&ch='.$ch.'" alt="Test" />';
echo '';
echo '<center>'.$r['title'].'</center>';
echo '</div>';
echo '</div>';
}
}