Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> skrypt galerii - prosze o pomoc, tworze skrypt galerii ale mi nie idzie
Przemo1980
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 29.03.2005

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


Witam,

chcialbym napisac prosty skrypt ktory pobiera zdjecia z danego katalogu i wyswietla je w dwoch kolumnach, i to wszystko.
do tej pory napisalem taki kod ale mam problem z tym zeby zdjecia dodawaly sie w dwoch kolumanach, najczesciej wyswietla mi sie tylko jedna kolumna z dwoma pustymi obrazakmi na poczatku ( odnosnik do katalogu a nie do konkretnego zdjecia)

  1. </head>
  2. <body>
  3. <table border=\"0\" align=\"center\" width=\"500\" height=\"308\">
  4.  <tr>
  5. <?php 
  6. $dir=&#092;"src\";
  7.  
  8. $file=array();
  9.  
  10. if (is_dir($dir)) { 
  11.  if ($dh=opendir($dir)) {
  12.  
  13.  while(($file=readdir($dh))!==false) {
  14.  
  15. $ile=count($file);
  16. // to ponizej to na czuja napisalem  
  17.  $files[]=$ile;
  18. if($files%2==0) {
  19. echo &#092;"<td><a href=$dir/\".$file.\" target=blank><img src=$dir/\".$file.\" style=\"border: 1px black solid\" width=170 height=138></a></td>\";
  20. } 
  21. else 
  22. { 
  23. echo &#092;"<td><a href=$dir/\".$file.\" target=blank><img src=$dir/\".$file.\" style=\"border: 1px black solid\" width=170 height=138></a></td></tr><tr>\";
  24. } 
  25.  }
  26. closedir($dh); 
  27.  } 
  28. } 
  29.  
  30.  
  31.  
  32.  
  33. ?>



prosze o pomoc bo mi nerwy juz wysiadą (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tiraeth
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

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


sprawdź to:
  1. <table border=\"0\" align=\"center\" width=\"500\" height=\"308\">
  2. <tr>
  3. <?php
  4. $dir = &#092;"img\";
  5.  
  6. $i = 0; # potrzebne do wprowadzania <tr>
  7.  
  8. if(is_dir($dir))
  9. {
  10.  if($dh=opendir($dir))
  11.  {
  12. while(($file=readdir($dh)) !== false)
  13. {
  14.  if($file !== '.' && $file !== '..')
  15.  {
  16. if($i%2)
  17. {
  18.  echo '<td>
  19. <a href='.$dir.'/'.$file.' target=\"blank\">
  20.  <img src='.$dir.'/'.$file.' style=\"border: 1px black solid\" width=\"170\" height=\"138\">
  21. </a>
  22.  </td></tr><tr>';
  23. }
  24. else
  25. {
  26.  echo '<td>
  27. <a href='.$dir.'/'.$file.' target=\"blank\">
  28.  <img src='.$dir.'/'.$file.' style=\"border: 1px black solid\" width=\"170\" height=\"138\">
  29. </a>
  30.  </td>';
  31. }
  32. $i++;
  33.  }
  34. }
  35. closedir($dh);
  36.  }
  37. }
  38. ?>
  39. </tr>
  40. </table>


Ten post edytował Tiraeth 29.03.2005, 17:39:02
Go to the top of the page
+Quote Post

Posty w temacie


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: 13.10.2025 - 06:30