Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/147002-solved-diplay-images-in-directoryurgent/
Share on other sites

<?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?

        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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.