Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Galeria obrazków, Problem z przeglądaniem.
habbakuk
post
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 22.03.2005

Ostrzeżenie: (0%)
-----


Cześć!
Mam gotowy sktypt z książki mówiący o tym jak zrobić galerię zdjęć z podpisami. Ja zaś chcę zrobić takiego myka, że wyświetlają mi się miniaturki obrazków zawartych w katalogu images. Po kliknięciu na miniaturkę otworzyłby się pełnowymiarowy obrazek. Każda miniaturka ma swój podpis. Wszystko działa poza faktem, iż miniaturki nie pokazują się (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) Opisy są, po kliknięciu na miniaturkę (wyświetlana jako pusty kwadrat z obramowaniem) otwiera się pełnowymiarowy obrazek. Co z tym fantem zrobić? Oto kod:
  1. <html>
  2. <head>
  3. <title>:: księgarnia - wybierz książkę ::</title>
  4. <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">
  5. </head>
  6. <body>
  7. <table border=\"0\"><tr>
  8.  
  9. <?php
  10. $dir = &#092;"images/\";
  11. $realDir = &#092;"/var/www/projekt/images/\";
  12. $cols = 1;
  13. $width = 200;
  14. $counter = 1;
  15.  
  16. if(!($fd = opendir($dir))) exit;
  17. while (($file = readdir($fd)) !== false){
  18.  if($file != &#092;".\" && $file != \"..\"){
  19. $ext = substr($file, strlen($file) - 3, 3);
  20. $ext = strtolower($ext);
  21. if($ext <> &#092;"jpg\") continue;
  22. if(!($size = @getimagesize($dir.$file))){
  23.  continue;
  24.  }
  25. $name = substr($file, 0, strlen($file) - 4);
  26. $name = $name.&#092;".txt\";
  27. if(file_exists($realDir.$name)){
  28.  if(!($fp = fopen($realDir.$name, &#092;"r\"))){
  29. $str = &#092;"Bez opisu\";
  30. }
  31.  else{
  32. $str = fgets($fp);
  33. }
  34.  fclose($fp);
  35. }
  36.  else{
  37.  $str = &#092;"Bez opisu\";
  38.  }
  39. $img_w = $size[0];
  40. $img_h = $size[1];
  41. $ratio = $img_w / $img_h;
  42.  
  43. if($ratio > 1){
  44.  $img_w = $width;
  45.  $img_h = ($width / $ratio);
  46. }
  47.  
  48. else{
  49.  $img_w = ($width * $ratio);
  50.  $img_y = $width;
  51. }
  52.  
  53. echo(&#092;"rn<td align=\"center\" valign=\"middle\">rn\");
  54. echo(&#092;"<a href=\"$dir$file\">\");
  55. echo(&#092;"<img src=$dir$file\"\");
  56. echo(&#092;"width=\"$img_w\" height=\"$img_h\">\");
  57. echo(&#092;"</a>\");
  58. echo(&#092;"<br>\".$str);
  59. echo(&#092;"rn</td>rn\");
  60.  
  61. if(($counter >= $cols) && (($counter % $cols) == 0)){
  62.  echo(&#092;"rn</tr><tr>rn\");
  63.  }
  64. $counter++;
  65.  }
  66. }
  67. echo(&#092;"rn</tr>rn\");
  68. closedir($fd);
  69. ?>
  70. </table>
  71. </body>
  72. </html>
Go to the top of the page
+Quote Post
ennics
post
Post #2





Grupa: Zarejestrowani
Postów: 312
Pomógł: 0
Dołączył: 29.12.2004

Ostrzeżenie: (0%)
-----


na piewszy rzut oka, nie możesz tak zadeklarować zmiennej/zmiennych
  1. <?php
  2.  
  3. echo(&#092;"<a href=\"$dir$file\">\");
  4. echo(&#092;"<img src=$dir$file\"\");
  5. //... powinno być 
  6. echo(&#092;"<a href=\"$dir $file\">\");
  7. echo(&#092;"<img src=$dir $file\"\");
  8. // a najlepiej 
  9. print &#092;"<a href=\" . $dir . $file . \">\";
  10. ?>


Ten post edytował ennics 19.06.2005, 11:33:01
Go to the top of the page
+Quote Post
gu35t
post
Post #3





Grupa: Zarejestrowani
Postów: 57
Pomógł: 0
Dołączył: 15.05.2005

Ostrzeżenie: (0%)
-----


mowilem Ci ze ta ksiazka ma w ciu* bledów:
ma byc:
  1. <?php
  2. }
  3. $img_w = $size[0];
  4. $img_h = $size[1];
  5. $ratio = $img_w / $img_h;
  6.  
  7. if($ratio > 1){
  8. $img_w = $width;
  9. $img_h = ($width / $ratio);
  10. }
  11.  
  12. else{
  13. $img_w = ($width * $ratio);
  14. $img_h = $width; //tutaj blad
  15. }
  16. echo(&#092;"rn<td align=\"center\" valign=\"middle\">rn\");
  17. echo(&#092;"<a href=\"$dir$file\">\");
  18. echo(&#092;"<img src=\"$dir$file\"\");
  19. echo(&#092;"width=\"$img_w\" height=\"$img_h\">\");
  20. echo(&#092;"</a>\");
  21. echo(&#092;"<br>\".$str);
  22. echo(&#092;"rn</td>rn\");
  23.  
  24. ?>


Ten post edytował gu35t 19.06.2005, 11:47:47
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 08:21