anf.etienne Posted February 26, 2009 Share Posted February 26, 2009 i have this coding that uploads files and then displays the images within the directory created.....the problem i have is if i upload say 6 images it displays them over 3 columns instead of the full 5 columns set. On top of this it also displays placeholders where there should be a blank space if you go to http://ve-creative.com/test/8/templateEdit2.php and upload 2 images you can see what i mean. the code to view the images is below <?php $folderPath= $id; $full_path=$fileL; $path = "$folderPath"; // path to the directory to read ( ./ reads the dir this file is in) if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(!is_dir($file)){ $item[] = $file; } } } closedir($handle); } $total_items = count($item); $max_items = ceil($total_items / 5); // items per <td> $start = 0; $end = $max_items //generate the table ?> <center> <table width="650px" border="1" cellspacing="5" cellpadding="5" align="center"> <tr> <?php require_once 'js/iframeRS.js'; for($i=0; $i<5; $i++){ if($i != 0){ $start = $start + $max_items; $end = $end + $max_items; } echo "<td>"; for($x = $start; $x < $end; $x++){ $imageL= $path.$item[$x]; $img_path="http://ve-creative.com/test/8/$imageL"; // display the item echo '<center><p><img src= "'.$path.$item[$x] .'" height="100" width="100"></p></center>'; echo "<input type=CHECKBOX name=$imageL>"; echo "<a href=imgEdit.php?img=$img_path>[Edit / resize]</a><br>"; } echo "</td>"; } ?> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/ Share on other sites More sharing options...
blintas Posted February 26, 2009 Share Posted February 26, 2009 So wait - how many images do you want to show if I've uploaded 6? And how do you want it do display? 5 images 1 image? Quote Link to comment https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/#findComment-771743 Share on other sites More sharing options...
anf.etienne Posted February 26, 2009 Author Share Posted February 26, 2009 if i upload 6 i want it to display all.....5 images on the 1st row then start a new row for the 6th image. Quote Link to comment https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/#findComment-771746 Share on other sites More sharing options...
blintas Posted February 26, 2009 Share Posted February 26, 2009 Okay, then change your approach echo("<TR>"); while($array_of_images) { if($count == 5) { echo("</tr><tr>"); $count = 0;} echo("<td>image</td>"); $count++; } Quote Link to comment https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/#findComment-771750 Share on other sites More sharing options...
anf.etienne Posted February 26, 2009 Author Share Posted February 26, 2009 <?php require_once 'js/iframeRS.js'; for($i=0; $i<5; $i++){ if($i != 0){ $start = $start + $max_items; $end = $end + $max_items; } echo "<td>"; ?> i take it ill be replacing this part of the coding? Quote Link to comment https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/#findComment-771756 Share on other sites More sharing options...
blintas Posted February 26, 2009 Share Posted February 26, 2009 for($x = $start; $x < $end; $x++){ $imageL= $path.$item[$x]; $img_path="http://ve-creative.com/test/8/$imageL"; // display the item echo '<center><p><img src= "'.$path.$item[$x] .'" height="100" width="100"></p></center>'; echo "<input type=CHECKBOX name=$imageL>"; echo "<a href=imgEdit.php?img=$img_path>[Edit / resize]</a><br>"; } echo "</td>"; } this part... this is the display portion where u are having issues. There is no where to break columns here. Quote Link to comment https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/#findComment-771767 Share on other sites More sharing options...
anf.etienne Posted February 26, 2009 Author Share Posted February 26, 2009 im a noob to php i got this code through doing a tutorial....i have figured a way to deal with the issue but i am trying to get it into rows....thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/#findComment-771790 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.