lewisstevens1 Posted November 30, 2010 Share Posted November 30, 2010 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 More sharing options...
litebearer Posted November 30, 2010 Share Posted November 30, 2010 Most likely, this PHPFreaks tutorial will teach you to achive your objective http://www.phpfreaks.com/tutorial/basic-pagination Link to comment https://forums.phpfreaks.com/topic/220289-php-image-display/#findComment-1141573 Share on other sites More sharing options...
lewisstevens1 Posted December 3, 2010 Author Share Posted December 3, 2010 THANKYOU it works perfectly! x Link to comment https://forums.phpfreaks.com/topic/220289-php-image-display/#findComment-1142450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.