Hi all
I tried a shot in the dark with this but no go…I though I’d post it to see if I was heading on the right area.
here is the script…. a bit ruff still but hey…..baby steps.
it has a few problems but one at a time, I would like to have it loop the structure so there are 3 images across and 2 down.
[code=php]
<?php
//Variables
if (isset($_GET[“num1”])){
if ($_GET[“num1”] > 0){
$num1 = $_GET[“num1”];
}
else{
$num1 = 1;
}
}
else{
$num1 = 1;
}
if (isset($_GET[“num2”])){
if ($_GET[“num1”] > 0){
$num2 = $_GET[“num2”];
}
else{
$num2 = 6;
}
}
else{
$num2 = 6;
}
//Path
$path = “gallery/”;
$loc = explode(“/”, $_SERVER[“PHP_SELF”]);
$loc = $loc[(count($loc) – 1)];
// Open the folder
$dir_handle = @opendir($path) or die(“Unable to open $path”);
$num = $num1;
// Loop through the files
echo ‘<table border=”0″ align=”center”>’;
while ((false !== ($file = readdir($dir_handle))) && ($num >= $num1 && $num < $num2)){ // Check the numbers from the original GETs.
if ($file != “.” || $file != “..” || $file != $loc){
$files = array();
$pieces = explode(‘.’, $file);
$extension = $pieces[(count($pieces) – 1)];
$image = $pieces;
if( $extension == “jpg”){
echo “<tr>”;
echo “<td>$num<div align=’center’><img width=”100″ height=”100″ src='” . $path . $image[0] . “.” . $extension . “‘></div><div align=’center’>” . $image[0] . “</div></td>”;
$num++ ;
echo “<td>$num<div align=’center’><img width=”100″ height=”100″ src='” . $path . $image[0] . “.” . $extension . “‘></div><div align=’center’>” . $image[0] . “</div></td>”;
$num++ ;
echo “<td>$num<div align=’center’><img width=”100″ height=”100″ src='” . $path . $image[0] . “.” . $extension . “‘></div><div align=’center’>” . $image[0] . “</div></td>”;
$num++ ;
echo “</tr>”;
}
}
}
echo ‘</table>’;
echo ‘<div align=”center”>’;
echo ‘<br>’;
if (($num1 – 6) > 0){
echo ‘<a href=”‘ . $loc . ‘?num1=’ . ($num1 – 6) . ‘&num2=’ . ($num2 – 6) . ‘”><strong>BACK</strong></a>’;
echo ‘ | ‘;
}
else{
}
echo ‘<a href=”‘ . $loc . ‘?num1=’ . ($num1 + 6) . ‘&num2=’ . ($num2 + 6) . ‘”><strong>NEXT</strong></a>’;
echo ‘</div>’;
// Close
closedir($dir_handle);
?>
This formats it the way I want but Doesn’t give different images across…I not to sure how to do that I thought maybe something like: $image[0] then $image[1] and $image[2] but I tried that and still no go.
The good part was that the $num number where all set out correctly.
Try it and you’ll see what I meen.
here is a link to a demo of the script so far:
[URL=http://members.lycos.co.uk/cybercampbell/gallery/gallery.php]http://members.lycos.co.uk/cybercampbell/gallery/gallery.php
and here is a link to the original post if you’d like to have a go at the other issues with the script.
[URL=http://www.webdeveloper.com/forum/showthread.php?s=&postid=243087#post243087]http://www.webdeveloper.com/forum/showthread.php?s=&postid=243087#post243087
Cheers
Chris