joopnoot Posted May 30, 2007 Share Posted May 30, 2007 I have a gallery script, when I put pictures in a folder, they will be shown. I want to link each picture to a textfile (.txt) that describe the picture. You can see what I mean here: http://www.landingpagetest.com/foto.php?foto=0&offset=0 When I change: getInfo($name); to getInfo("test"); than it works, but this is just an txt file in the map, Theres no link to the pictures. I think $name isn't working well.. (I am a NOop with php so....) Can someone help me out? Here is my schript: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style> a.pijl{ font-family:Arial, Helvetica, sans-serif; font-size:24px; text-decoration:none; } a.over{ font-family:Arial, Helvetica, sans-serif; font-size:16px; text-decoration:none; } .pijltjes{ margin-top:340px; } </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Foto</title> </head> <body> <table width="380" border="1" align="left" cellpadding="0" cellspacing="0"> <tr> <td width="20" align="center" valign="middle"> <? $weergeef=array(); $width=array(); $height=array(); $bestanden_arr=array(); $dir = 'fotos'; $aantal_bestanden=0; $aantal_foto=0; if (@$handle = opendir($dir)) { while (false!== ($file = readdir($handle))) { if($file!= "." && $file!= "..") { $fName = $file; $bestand = $dir.'/'.$file; $bestanden_arr["$aantal_bestanden"]=$bestand; $aantal_bestanden++; } } } $arraysize=sizeof($bestanden_arr); $aantal_foto=0; for($i=0;$i<$arraysize;$i++){ $pathinfo = pathinfo($bestanden_arr[$i]); $extension = $pathinfo["extension"]; if (($extension=="jpg")||($extension=="gif")||($extension=="bmp")||($extension=="png")) { $weergeef["$aantal_foto"]=$bestanden_arr["$i"]; $aantal_foto+=1; } } $offset=$_GET['offset']; $lengte=9; $de_foto=$_GET['foto']; $output = array_slice ($weergeef, $offset, $lengte); $size = getimagesize($output[$de_foto]); $breedte=$size['0']; $hoogte=$size['0']; $width=$breedte; $height=$hoogte; $terug=$_GET['foto']; $eind=$_GET['offset']; $eind2=$_GET['offset']; $aantal_pagina=ceil($aantal_foto/9); $max=9*$aantal_pagina; $max-=9; $bla=$aantal_foto-$eind; $bla-=1; ?> <? if(($terug<=0)&&($eind==0)){ echo " "; }elseif(($terug<=0)&&($eind>0)){ $eind-=9; $min=8; echo "<a class=\"pijl\" href=\"foto.php?foto=$min&offset=$eind\">«</a>"; }else{ $min=$terug-1; echo "<a class=\"pijl\" href=\"foto.php?foto=$min&offset=$eind\">«</a>"; } ?></td> <td width="320" height="320" align="center" valign="middle"><img src="<? echo $output[$de_foto];?>"/></td> <td width="20" align="center" valign="middle"><? if(($terug==$bla)&&($eind2==$max)){ echo " "; }elseif(($terug>=&&($eind2<$max)){ $eind2+=9; $min=0; echo "<a class=\"pijl\" href=\"foto.php?foto=$min&offset=$eind2\">»</a>"; }else{ $min=$terug+1; echo "<a class=\"pijl\" href=\"foto.php?foto=$min&offset=$eind2\">»</a>"; } ?> </td> </tr> <tr> <td height="200" colspan="3" align="center" valign="middle" style="font-family: "> <?php function getInfo($name){ $map = "/home/niels/domains/landingpagetest.com/public_html/fotos/"; # map van de textbestanden! $file =$map.$name.".txt"; echo "file: ".$file."<br/>\n\r"; if(file_exists($file) && is_readable($file)){ $blaat = include_once($file); } else{ echo "file: ".$file." Can not be found...<br/>\n\r"; } } getInfo($name); ?> </td> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/53545-how-to-link-text-to-photos-in-gallery-no-database/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.