plugnz Posted May 17, 2010 Share Posted May 17, 2010 Hi there, I am trying to display images from a database selected and want the images to fill the page horizontally rather than vertically. The code I have got so far kind of gets there but I get the top row repeating the same image. Code is as follows: $ImageDir = "img/category/"; $ImageThumb = $ImageDir . "thumbnails/"; $getpic = "SELECT image_id, image_group, image_name, location_no " . "FROM cms_images_category " . "WHERE category_name = '" . $_GET['category'] . "'"; "ORDER BY image_group "; $results = mysql_query($getpic,$conn) or die(mysql_error()); while ($row = mysql_fetch_array($results)) { extract($row); $images = $ImageThumb . $image_id . ".jpg"; $i = 0; //echo "<table> \n"; for ($y=1;$y<=2;$y++) { echo "<tr> \n"; for ($x=1;$x<=3;$x++) { echo "<td><h2>" . $image_group . "</h2></td>\n"; echo "<td><a href =\"".$ImageDir . $image_id . ".jpg\" target='top'>"; echo "<img src=\"".$images[$i++] . "\"></a></td>\n"; echo "<td><h2>" . $image_name . "</h2></td>\n"; } echo"</tr> \n"; } } As soon as I try to add [$i++] after the $images the images disappear. take it out and get my images back but repeated three times on each row... What am I doing wrong here? Link to comment https://forums.phpfreaks.com/topic/202028-arranging-images-to-fill-all-available-space/ Share on other sites More sharing options...
scvinodkumar Posted May 17, 2010 Share Posted May 17, 2010 i think you have not pasted right code here, so please re-post that php code Link to comment https://forums.phpfreaks.com/topic/202028-arranging-images-to-fill-all-available-space/#findComment-1059416 Share on other sites More sharing options...
plugnz Posted May 17, 2010 Author Share Posted May 17, 2010 Ok, here it is again but just the bit pertaining to the for loop while ($row = mysql_fetch_array($results)) { extract($row); $images = $ImageThumb . $image_id . ".jpg"; $i = 0; //echo "<table> \n"; for ($y=1;$y<=1;$y++) { echo "<tr> \n"; for ($x=1;$x<=3;$x++) { echo "<td><h2>" . $image_group . "</h2></td>\n"; echo "<td><a href =\"".$ImageDir . $image_id . ".jpg\" target='top'>"; echo "<img src=\"".$images[$i++] . "\"></a></td>\n"; echo "<td><h2>" . $image_name . "</h2></td>\n"; } echo"</tr> \n"; } } Link to comment https://forums.phpfreaks.com/topic/202028-arranging-images-to-fill-all-available-space/#findComment-1059420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.