cerberus478 Posted September 9, 2011 Share Posted September 9, 2011 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; } } } Quote Link to comment https://forums.phpfreaks.com/topic/246765-looping-images/ Share on other sites More sharing options...
9mileshq Posted September 9, 2011 Share Posted September 9, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246765-looping-images/#findComment-1267283 Share on other sites More sharing options...
cerberus478 Posted September 9, 2011 Author Share Posted September 9, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246765-looping-images/#findComment-1267289 Share on other sites More sharing options...
cerberus478 Posted September 14, 2011 Author Share Posted September 14, 2011 thanks to the people that tried to help but I managed to find a solution Quote Link to comment https://forums.phpfreaks.com/topic/246765-looping-images/#findComment-1269249 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.