Jump to content

looping images


cerberus478

Recommended Posts

Hi

 

I have two albums with pictures in them, what I want to know is how do I put the first image of my album next to the albums name. For example I have an album called gallery 1 and I have 2 pictures in it and before you click the link to go see those images i want the first picture to be next to gallery 1. I hope that made sense. Thank you for your help.

 

This is the code I got so far

 

public function home(){

 

$galleries_model = new galleries_model('galleries');

$galleries = $galleries_model -> get_all();

 

 

 

foreach($galleries as $gallery){

 

$sql = ("SELECT * FROM gallery_images WHERE id = gallery_id LIMIT 1");

 

 

$this->_params['list'][] = $gallery;

}

 

 

 

 

}

 

 

 

 

}

Link to comment
Share on other sites

A bit confused what your trying to do, or asking to do.

 

Just from looking at your code what exactly are you trying to achieve in the function with:

 

$this->_params['list'][] = $gallery;

 

I presume this is a property within the class this function is? You don't need the [] bracket to start with, as 'list' would be the key and $gallery would be the value...

 

Are you using a Framework? As you have defined an SQL statement, but not actually doing anything with it? If you could provide some more information with more code and say exactly what your trying to do, might be able to help.

 

 

 

 

Link to comment
Share on other sites

I'm using a zend framework. I have a page that has a list of galleries and when I click on the link it takes me to another page called gallery 1 which has the pictures. so what I want is the pages.controller.php to go through my database and give me the first image for that gallery and show it next to the gallery 1 link on my home.php

 

$this->_params['list'][] = $gallery();

 

is suppose to be a way to link my pages.controller.php to my home.php

 

my home.php has

 

foreach ($this->_params['list'] as $key => $gallery ){

$gallery_name = $gallery['name'];

$image = $gallery['image_path'];

 

echo "<table>";

echo "<tr>";

echo "<td>";

echo "<img src='/image.php?path=$image&h=50&w=50'>";

echo "<a href=/galleries/view/".$gallery['id'].">$gallery_name</a>";

echo "</td>";

echo "</tr>";

echo "</table>";

}

 

but it doesn't work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.