Pulling images by group from the database
Posted: Wed Mar 05, 2014 12:48 pm
Some how I need to get 1 group (Weddings) then cycle through the image names in that group then once that is done i need to go to the next group (5points) and display the 2 images in that div and so on. Weddings -> 2 images, 5points -> 2 images and Misc -> 2 images. It is putting each image in a separate div. The Wedding, 5points and Misc has 2 images each I am getting 6 divs with 1 image in each I should have 3 divs (wedding, 5points and misc) with 2 images displayed in each of the 3 divs. Hopefully I have explained a little better. This is driving me up the wall XD. Thanks all.
I have been working on this for days. I can't seem to get it exactly how I want it to display. Can anyone help on this matter? Thanks.
Code: Select all
$pgroup = $Sys->db->query("SELECT dj_photo_group.photo_group, dj_photo.name, dj_photo.img_group FROM dj_photo_group, dj_photo WHERE dj_photo_group.photo_group = dj_photo.img_group ORDER BY dj_photo.img_group DESC");
while($photo = $pgroup->fetch_object()) {
echo '<div class="photo_head">' . ucfirst($photo->photo_group) . '</div>';
echo '<div class="photo_sub">';
while($photo->name) {
echo '<img src="photogallery/' . $photo->photo_group . '/' . $photo->name . '" />';
}
echo '</div>';
}