next and back in an image gallery
Posted: Wed Sep 28, 2005 3:28 pm
im still stuck up wid this image gallery thingy..
i need to navigate within the gallery using back and next btns..but i dont have a database...one idea wud be to get the name of all the images in a folder in an array and then call it to display the next and back images..
i need to navigate within the gallery using back and next btns..but i dont have a database...one idea wud be to get the name of all the images in a folder in an array and then call it to display the next and back images..
Code: Select all
<?php
//get directory contents
$contents = array();
$dir = opendir('thimg');
while (false !== ($file = readdir($dir))) {
$contents[] = $file;
}
closedir($dir);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Get Directory</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<?
/* // Print file names
foreach($contents as $file){
if(($file != '.') and ($file != '..')){
print ($file . '<br>');
}
} */
?>
</body>
</html>
<a href='<? echo"display.php?img=$file[]"?>'>previous</a>//i dont know how to call it here
<a href='<? echo"display.php?img=$file[]"?>'>next</a>
<?php
$url_path = "upimg";
$dir = dir($url_path);
$imagename=$_GET['img'];
{if($entry == "." || $entry == "..") {
continue;
}
echo"<center>";?>
<a href="image.php"><img src='<? echo"$url_path/$imagename"?>'></a>
<? echo "</center>";}?>