Hi,
I'm Gemma and I'm in need of some serious help. I'm new to php and so I'm sure there are better methods of achieving a horizontal images web page, but if anyone knows how to make it work with the readdir function, I'd be so happy as it's the simplest method I've come across so far, and no arrays!!! Arrays aren't my favourite thing in the world. I'm sure there are answers out there but I've found the readdir method the simplest so far, which works great for doing exactly what I want it to do.
Basically, the objective is to display images from the image (IMG) folder/directory inline, horizontally. However, in the process, two unidentified blank image holders have come up before my first real image, and one unidentified image holder has come up after my last real image. I have no additional images in the folder so I don't know why it is doing this?
<html>
<head><title>Horizontal Pages</title>
<style type="text/css">
#box {
width:12000px;
}
#images img{
height:500px;
float:left;
display:inline;
}
</style>
</head>
<body>
<div id="box">
<?php
if ($handle = opendir('IMG')) {
while (false !== ($file = readdir($handle))) {
echo "<div id='images'>" . "<img src='IMG/" ."$file\n" . "'/>" . "</div>";
}
closedir($handle);
}
?>
</div>
</body>
</html>
If there is a better way, please let me know. Also, hopefully it's just a simple as the readdir method. I like it!
Also, I intend to use jquery or javascript to dynamically alter the width of the #box div, but just for now, I've set it to 12000px to fit in all the pictures.