Grodo Posted October 1, 2007 Share Posted October 1, 2007 Hello, Once again I come to the PHP Freaks community for help. I have spent serveral weeks trying to figure out how to do this. Attached below is code for a function that outputs images in a row. However I am tring to find a way so that it would output 5 images and then drop a line and continue to do this untill all the images have been displayed. The variable which the output is stored in is named $out (towards the bottom). The variable $thumb_row is the total number of images that are allowed to be displayed. Here is an illustration of what I am trying to do the X is an image. XXXXX XXXXX XXXXX XXXXX Thank you, Grodo function my_filmstrip($thumbnail_dir, &$template, $a_images, $currentPic, $thumb_row, $path_to_images) { global $path; global $auto_url; // get size of $a_images array... $number_pics = count($a_images); // do a little error checking... if ($currentPic > $number_pics) $currentPic = 0; if ($currentPic < 0) $currentPic = 0; if ($thumb_row < 0) $thumb_row = 1; if ($thumb_row > $number_pics) $thumb_row = $number_pics; if ($currentPic >= $thumb_row) { $start = $currentPic - $thumb_row + 1; } else { $start = 0; } $out = ''; for ($x = $start; $x < ($start + $thumb_row); $x++ ) { $item = preg_split('/;/', rtrim($a_images[$x]), 2); $class = $x == $currentPic ? 'thumbnail_center' : 'thumbnail'; if ($number_pics > 4) $out .= "\n<style type='text/css'>.img{opacity:1;filter:alpha(opacity=100)}a:hover img{filter:xray}</style><a href='$path?directory=$path_to_images$auto_url¤tPic=$x' class='thumbnail'><img src='$path_to_images/$thumbnail_dir/".$item[0]."' class='$class'></a>"; } $template = str_replace("<THUMBNAIL_ROW>",$out,$template); } Quote Link to comment https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/ Share on other sites More sharing options...
pocobueno1388 Posted October 2, 2007 Share Posted October 2, 2007 Take a look at this post http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Quote Link to comment https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/#findComment-359709 Share on other sites More sharing options...
Grodo Posted October 2, 2007 Author Share Posted October 2, 2007 Thanks pocobueno1388 ill look over the post and let you know how the development is comming along Quote Link to comment https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/#findComment-359716 Share on other sites More sharing options...
Grodo Posted October 2, 2007 Author Share Posted October 2, 2007 I have read over through the post but im still confused on how to input that into a variable.... This is what i came up with $i = 0; if ($i == 0) echo "<tr>"; echo "Image Goes Here" if (++$i == $max_imagerow) { echo "</tr>"; $i=0; } what would be the best way to put it into one. Quote Link to comment https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/#findComment-359724 Share on other sites More sharing options...
Grodo Posted October 3, 2007 Author Share Posted October 3, 2007 * Bump * The reason why i need it in a variable is because that variable then is passed into a templete html file Quote Link to comment https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/#findComment-361159 Share on other sites More sharing options...
Grodo Posted October 3, 2007 Author Share Posted October 3, 2007 My new code but still no luck someone please help for ($x = $start; $x < ($start + $thumb_row); $x++ ) { $item = preg_split('/;/', rtrim($a_images[$x]), 2); $class = $x == $currentPic ? 'thumbnail_center' : 'thumbnail'; $out .= "\n<style type='text/css'>.img{opacity:1;filter:alpha(opacity=100)} a:hover img{filter:xray}</style> <a href='$path?directory=$path_to_images$auto_url¤tPic=$x' class='thumbnail'> <img src='$path_to_images/$thumbnail_dir/".$item[0]."' class='$class'></a>"; for ($check =0; $check < $thumb_row; $check++) { if ($check=4) $out = $out + "<br>"; if ($check= $out = $out + "<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/#findComment-361210 Share on other sites More sharing options...
Grodo Posted October 3, 2007 Author Share Posted October 3, 2007 I just used css to format the images into rows of 4 Quote Link to comment https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/#findComment-361223 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.