i know this question has been asked already and I found a few answers but it would be soo great if anyone could help me with this script, which just browses images on a webpage in an image folder on a server.
the script so far is working (a friend gave it to me):
http://dev.perfectday.gb.com/tom/chiaraweb/photo.php
the number on the images are the filenames. I want to order the images by filenames.
the only thing is the order of the images.
I know there is a way with scandir but as I am a beginner with php I am not able to fit the right piece of code into the right bit of my photos.php.
if anyone could tell me how I can make this work would be amazing.
I am making this website for a freind so that I cannot hire any programmer for that :(
this is the code of the photo.php.
I didnt ue the part with the category.
thanks a lot
kirstenkirsche
............... ............... ...............
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <title>Chiara Romagnoli Photographer</title>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <link href="style.css" rel="stylesheet" type="text/css">
- <script type="text/javascript">
- <!--
- function MM_preloadImages() { //v3.0
- var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
- var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
- if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
- }
- //-->
- </script>
- </head>
- <body>
- <table align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td><a href="index.html"><img src="pictures/header.gif" alt="Chiara Romagnoli Photographer" width="501" height="84" /></a></td>
- </tr>
- <tr>
- <td><div align="right"><a href="photo.php"><img src="pictures/gallery.gif" alt="gallery" width="62" height="20"></a><a href="about.html"><img src="pictures/about.gif" alt="about" width="60" height="20"></a><a href="contact.html"><img src="pictures/contact.gif" alt="contact" width="75" height="20"></a></div></td>
- </tr>
- </table>
- <table border="0" cellspacing="0" cellpadding="5" align="center">
- <tr>
- <td align="center">
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td>
- <div align="center"><br>
- <?php
- $Pfadcat1 = "./pictures/gallery/";
- $Pfadcat2 = "./photos/2/";
- $Pfadcat3 = "./photos/3/";
- #echo "<hr>index-übergeben<br>"."$index"."<hr>";
- #echo "<hr>cat-übergeben<br>"."$cat"."<hr>";
- #echo "Per POST übergebene Variablen:<br>\n";
- while (list ($key, $val) = each ($_GET))
- {
- #echo "$key => $val<br>";
- if ($key=="cat")
- {
- $cat=$val;
- }
- if ($key=="index")
- {
- $index=$val;
- }
- }
- #echo "<hr>index-übergeben<br>$index<hr>";
- #echo "<hr>cat-übergeben<br>$cat<hr>";
- if ($cat==1)
- {
- $Pfad = $Pfadcat1;
- }
- if ($cat==2)
- {
- $Pfad = $Pfadcat2;
- }
- if ($cat==3)
- {
- $Pfad = $Pfadcat3;
- }
- if (($cat!=1)&&($cat!=2)&&($cat!=3))
- {
- $Pfad = $Pfadcat1;
- }
- #echo $Pfad;
- #echo "<hr>index-übergeben<br>$index<hr>";
- #echo "<hr>cat-übergeben<br>$cat<hr>";
- $counter = 0;
- #anzahl datein ermitteln
- $i=0;
- $verz=opendir ($Pfad);
- while ($file=readdir($verz))
- {
- if (filetype($Pfad.$file)!="dir")
- {
- $i++;
- #echo "<br>.$file";
- }
- }
- closedir($verz);
- #linkzähler ermitteln
- #echo "<hr>anzn<br>".$i."<hr>";
- #sicherheit
- if($index<1||$index>$i)
- { $index = 1;}
- $prev = $index-1;
- $next = $index+1;
- if($prev<1)
- { $prev = $i;}
- if($next>$i)
- { $next = 1;}
- if($Verzeichniszeiger = opendir($Pfad))
- {
- while($Datei = readdir($Verzeichniszeiger))
- {
- if($Datei != "." && $Datei != "..")
- {
- $Bilddaten = getimagesize($Pfad.$Datei);
- $counter++;
- #echo "<hr>".$counter."<hr>";
- if($index==$counter)
- {
- ?>
- <table border="0" align="center" cellpadding="5" cellspacing="0">
- <tr>
- <td colspan="3">
- <div align="center">
- <table width="100" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF">
- <tr>
- <td>
- <div align="center"><a href="photo.php?index=<?php echo$next; ?>&cat=<?php echo$cat; ?>"><img src="<?php echo$Pfad.$Datei; ?>"></a><br>
- <?php
- }
- }
- }
- closedir($Verzeichniszeiger);
- }
- #echo "<hr>".$counter."<hr>";
- ?> </div> </td>
- </tr>
- </table>
- </div></td>
- </tr>
- <tr valign="top">
- <td height="25"><a href="photo.php?index=<?php echo$prev; ?>&cat=<?php echo$cat; ?>"><img src="images/button1.gif" alt="1" border="0"></a></td>
- <td height="25"><div align="center"></div></td>
- <td height="25"><div align="right"><a href="photo.php?index=<?php echo$next; ?>&cat=<?php echo$cat; ?>"><img src="images/button2.gif" alt="2" border="0"></a></div></td>
- </tr>
- </table>
- </div> </td>
- </tr>
- </table> </td>
- </tr>
- </table>
- <div align="center"></div>
- </body>
- </html>