Jump to content

PHP Image Display


lewisstevens1

Recommended Posts

Hi im wanting to create this system where it loads all your files in a specified directory, loads all the images, although i have done that what im trying to do is have it so it prints them into a 9x9 grid automatically, in which i need to find something to restrain the echo of the variable to a limit of 9..  i need to create the <tr><th>and <td>'s automatically and also id like it so if there is more than 9, it will allow me to select a button which will load up the next section of images. heres the code i have so far:

 

<?php
$dir = "images/";
$dh  = opendir($dir);
while (false !== ($filename = readdir($dh))) {
    $files[] = $filename;
}

sort($files);
print_r($files); 

 

I then used this to try and echo into a table :S

<?php
if ($handle = opendir('images/')) {


      while (false !== ($file = readdir($handle))) {
  echo "<table width='450px' height'450px' border='4px solid #000'>";
	if ($file != "." && $file != ".."){
		echo "<tr><td>$file<br></td>";
	echo "<td><img src=images/".$file." height='20px' width='20px'></td></tr><br>";
    }
}
echo "</table>";
closedir($handle);
}

?>

 

They are seperate as i havent merged together as i wud like to get them working first.

 

I was trying to do the max and min on the array numbers but was stuck doing that.

 

Any help would be greatly apprecated

Many thanks

Lewis Stevens

Link to comment
https://forums.phpfreaks.com/topic/220289-php-image-display/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.