This has been driving me crazy, I need to select a specific row then select the next two rows with specific conditions.
What I have is a photo gallery, with photo ablums. Each photo album has an ID and each photo within the album has an ID as well. I want to show the first three photos within an album as a preview for the album. The problem is that I’m getting the same image for all three previews.
Also I redoing someone elses code which makes this seem harder.
Here’s the function that calls the photo:
public function getPhotos($album_id)
{
$sql = 'SELECT COUNT(photo_id) AS total_photos, photo_id, photo_ext, s_width, s_height,'.
' photo_server_url FROM '.$this->CFG['db']['tbl']['photo'].
' WHERE photo_album_id='.$this->dbObj->Param('photo_album_id').
' AND photo_status='Ok' GROUP BY photo_album_id';
$stmt = $this->dbObj->Prepare($sql);
$rs = $this->dbObj->Execute($stmt, array($album_id));
if (!$rs)
trigger_error($this->dbObj->ErrorNo().' '.$this->dbObj->ErrorMsg(), E_USER_ERROR);
$this->total_photos = 0;
if($row = $rs->FetchRow())
{
$this->photo_id = $row['photo_id'];
$this->photo_ext = $row['photo_ext'];
$this->s_width = $row['s_width'];
$this->s_height = $row['s_height'];
$this->photo_server_url = $row['photo_server_url'];
$this->total_photos = $row['total_photos'];
return true;
}
}
Ok now here’s where it’s called:
public function showAlbum()
{
$photos_folder = $this->CFG['media']['folder'].'/'.$this->CFG['admin']['photos']['folder'].'/';
while($row = $this->fetchResultRecord())
{
?>
<tr>
<?php
$photo_path = $this->photo_server_url.$photos_folder.getImageName($this->photo_id).$this->CFG['admin']['photos']['small_name'].'.'.$this->photo_ext;
//$photo_id is what I want to increment by 1 to the next photo in the album with my specifications
// Below is the skeleton of what I've been messing around with, I've tried while loops as well but haven't been able to come up with anything decent
?>
<td id="PhotoGallery">
<img src="<?php echo $photo_path;?>"/>
<img src="<?php echo $photo_path;?>"/>
<img src="<?php echo $photo_path;?>"/>
</td>
</tr>
<?php
}
}
?>
Sorry for the long post, but this has been driving me mad. If anyone can help it would be greatly appreciated.
Thanks,
Vijay