sooty2006 Posted May 12, 2008 Share Posted May 12, 2008 hi,i am making an image gallery for my site and every 3 images i want to make a new line so i dont have a long line of images i have tried everything i know!but i know you can do it using the count function!but i am unsure how to use it properly could anyone give me any tips or show me how to do it?i will be very greatfull! :)scott Link to comment Share on other sites More sharing options...
zppblood Posted May 12, 2008 Share Posted May 12, 2008 <?php $images=array('blah.jpg', 'one.gif', 'something.jpg', ...list keep on going); // Or however you get the names of the files for($i=0; $i<count($images); $i++) { echo '<img src="'.$images[$i].'">'; if($i%3==2) { echo '<br>'; } }?> Link to comment Share on other sites More sharing options...
sooty2006 Posted May 13, 2008 Author Share Posted May 13, 2008 thanks alot mate it works thank you all! Link to comment Share on other sites More sharing options...
sooty2006 Posted May 13, 2008 Author Share Posted May 13, 2008 erm sorry i tryed it changing the imagesbut now theres another problem!heres my script: <?phpif ($_GET['show_page']) {$get_tot = $_GET['show_page'];$query42 = mysql_query("SELECT * FROM image_gallery ORDER BY id DESC LIMIT $get_tot , 12");}else{$query42 = mysql_query("SELECT * FROM image_gallery ORDER BY id DESC LIMIT 0 , 12");}$rows42 = mysql_num_rows($query42);$i = 0;while($i <= $rows42) {$array = mysql_fetch_array($query42);echo "<img src=\"handle_image.php?w=90&h=90ℑ=$array[image_link]\">";if($i%3 == 2) {echo "<br>";}$i ++;}?> it makes a new line for every 3 images like it should do but...it makes an image not in the directory i have checked everything!visit http://www.gcjconstruction.co.uk/index.phpand visit image gallery you will see what i meanwhy is it doing that please help me!thanks! Link to comment Share on other sites More sharing options...
justsomeguy Posted May 13, 2008 Share Posted May 13, 2008 Change this:while($i <= $rows42) {$array = mysql_fetch_array($query42);to this:while ($array = mysql_fetch_array($query42)) {$i++;Or just make it less than instead of less than or equal. Link to comment Share on other sites More sharing options...
sooty2006 Posted May 13, 2008 Author Share Posted May 13, 2008 thanks never even thought of that! :)who knew something so simple could be such a problem lol! thanks alot, justsome guy u saved me again! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.