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
Share on other sites

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.