i went through a tutorial on how to display images stored with a directory and it came out good but i have a problem.....when i upload less than 5 files it displays the 1 image and then shows broken image placeholders. If i don't upload in sums of 5 then these broken image places holders keep showing, and instead of the images displaying row by row it goes by columns.
Below is the code to display....can someone tell me where i've gone wrong or how i can change this so it displays the uploaded images in rows of 5?
Expand|Select|Wrap|Line Numbers
- <?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>
- </div> <!--end:mult.pictures-->
- <table width="100%" border="0" cellpadding="5">