Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Źłe wyświetlanie
Arsanael
post
Post #1





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 4.06.2009

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


mam kod ktory powinien (przynajmniej według moich zamierzen) wyswietlac miniaturki z odnosnikiem do normalnego pliku(nie pomniejszonego). Niestety wyswietlając miniaturke obrazu np. x odnośnik jest do innego pliku normalnego dajmy na to y.
Czyli to tak: wyswietla mi obrazek mini_obraz1.png a odnosnik jest do obraz4.png zamiast obraz1.png.

Chyba coś źle wykodziłem, mogłby ktoś luknąc?

Kod
$data_sesion = $_SESSION["user"];
$t=1;
    $i = 0;
        if ($handle = opendir('miniaturki/'.$data_sesion.'/'))
            {        
        while (false !== ($file[$i] = readdir($handle)))
                    {
                            if ($file[$i] != "." && $file[$i] != ".." && $file[$i] != "index.html")
                                        {
                            
                                        $i++;
            }
        
        }
    }



$j = 0;
if ($handle2 = opendir('profil/'.$data_sesion.'/'))
            {    
                while (false !== ($file2[$j] = readdir($handle2)))
                    {
                                if ($file2[$j] != "." && $file2[$j] != ".." && $file2[$j] != "index.html")
                                    {
                        
                                    echo "<a href='profil/$data_sesion/$file2[$j]/'><img                                         src='miniaturki/$data_sesion/$file[$j]'                                                           width=150 height=100></a>";
                        $j++;
                                    if ($t % 3 == 0) echo '<br /><br />';
                                    $t++;

                    }
                }
closedir($handle2);
closedir($handle);
            }

          
        }
Go to the top of the page
+Quote Post
vonski
post
Post #2





Grupa: Zarejestrowani
Postów: 292
Pomógł: 89
Dołączył: 27.12.2006
Skąd: Warszawa

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


Spróbuj tak:

  1. <?php
  2. if ($handle = opendir('profil/' . $data_sesion) AND $handle2 = opendir('miniaturki/' . $data_sesion))
  3. {
  4.  
  5.    while ((false !== ($file = readdir($handle))) AND (false !== ($file2 = readdir($handle2))))
  6.    {
  7.        if($file != "." AND $file != ".." AND $file != "index.html" AND $file2 != "." AND $file2 != ".." AND $file2 != "index.html")
  8.        {
  9.            echo "<a href=profil/" . $data_sesion . "/" . $file . "><img src=miniaturki/" . $data_sesion . "/" . $file2 . "></img></a>";
  10.                 if($t % 3 == 0)
  11.                        echo "<br /><br />";
  12.                 $t++;
  13.         }
  14.    }
  15.  
  16.    closedir($handle2);
  17.    closedir($handle);
  18. }
  19. ?>


Ten post edytował vonski 19.06.2009, 22:42:02
Go to the top of the page
+Quote Post
Arsanael
post
Post #3





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 4.06.2009

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


dalej to samo ;/
Go to the top of the page
+Quote Post
vonski
post
Post #4





Grupa: Zarejestrowani
Postów: 292
Pomógł: 89
Dołączył: 27.12.2006
Skąd: Warszawa

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


To ciekawe w sumie, u mnie to działa (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

A na pewno kolejność obrazków w obu katalogach jest dobra?
Chodzi mi o to, że np. 3 obrazek w katalogu "profil" musi odpowiadać trzeciemu obrazkowi z katalogu "miniaturki".
Go to the top of the page
+Quote Post
Savage.Mephisto
post
Post #5





Grupa: Zarejestrowani
Postów: 122
Pomógł: 11
Dołączył: 24.01.2008

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


Od kiedy to istnieje taki zapis?

Kod
<img src=miniaturki/" . $data_sesion . "/" . $file2 . "></img>
Go to the top of the page
+Quote Post
vonski
post
Post #6





Grupa: Zarejestrowani
Postów: 292
Pomógł: 89
Dołączył: 27.12.2006
Skąd: Warszawa

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


Proszę:

  1. <?php
  2. echo "<a href=\"profil/" . $data_sesion . "/" . $file . "\"><img src=\"miniaturki/" . $data_sesion . "/" . $file2 . "\" /></a>";
  3. ?>
Go to the top of the page
+Quote Post
Arsanael
post
Post #7





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 4.06.2009

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


Tyle ze to nie w tym tkwi błąd tylko w wyciąganiu nazw plików. Sprawdziłem wyswietlilem nazwy plików :

  1. <?php
  2. if ($handle = opendir('profil/' . $data_sesion) AND $handle2 = opendir('miniaturki/' . $data_sesion))
  3. {
  4.  
  5.   while ((false !== ($file = readdir($handle))) AND (false !== ($file2 = readdir($handle2))))
  6.   {
  7.       if($file != "." AND $file != ".." AND $file != "index.html" AND $file2 != "." AND $file2 != ".." AND $file2 != "index.html")
  8.       {
  9. echo '<b>'.$file.'</b>';
  10. echo ' ';
  11. echo $file2;
  12. echo ' ';
  13. echo '<br><br>';
  14.                if($t % 3 == 0)
  15.                       echo "<br /><br />";
  16.                $t++;
  17.        }
  18.   }
  19.  
  20.   closedir($handle2);
  21.   closedir($handle);
  22. }
  23. }
  24. ?>


Wyszło mi :

Cytat
product_one.jpg mini_13.jpg

sitebg.jpg mini_vallheru.jpg

vallheru.jpg mini_imagesas.jpg



upload.jpg mini_product_one.jpg

13.jpg mini_sitebg.jpg

imagesas.jpg mini_upload.jpg



Teraz jak to odczytać tak aby sie zgadziały nazwy miniaturek i plików?
Go to the top of the page
+Quote Post
behu
post
Post #8





Grupa: Zarejestrowani
Postów: 52
Pomógł: 16
Dołączył: 8.08.2008
Skąd: London

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


skoro nazwy miniaturek masz 'mini_[nazwa oryginału]' możesz wczytać tylko katalog /profil/ i linki tworzyć w ten sposób:

  1. <?php
  2. echo "<a href=\"profil/" . $data_sesion . "/" . $file . "\"><img src=\"miniaturki/" . $data_sesion . "/mini_" . $file . "\" /></a>";
  3. ?>



albo całość może w ten sposób:
  1. <?php
  2. if ($handle = opendir('profil/' . $data_sesion) AND $handle2 = opendir('miniaturki/' . $data_sesion))
  3. {
  4.  
  5.  while ((false !== ($file = readdir($handle))) AND (false !== ($file2 = readdir($handle2))))
  6.  {
  7.      if($file != "." AND $file != ".." AND $file != "index.html" AND $file2 != "." AND $file2 != ".." AND $file2 != "index.html")
  8.      {
  9. $profil[] = $file;
  10. $mini[] = $file2;
  11.       }
  12.  }
  13.  
  14.  sort($profil);
  15.  sort($mini);
  16.  $profil_mini = array_combine($profil, $mini);
  17.  closedir($handle2);
  18.  closedir($handle);
  19. }
  20. ?>



i dopiero tworzyć linki:
  1. <?php
  2. $t=0;
  3. foreach($profil_mini as $klucz=>$wartosc){
  4.         echo "<a href=\"profil/" . $data_sesion . "/" . $klucz . "\"><img src=\"miniaturki/" . $data_sesion . "/" . $wartosc . "\" /></a>";
  5.  
  6. if($t > 0 && $t % 3 == 0){
  7.         echo "<br /><br />";
  8.         $t++;
  9. }
  10. }
  11. ?>


Ten post edytował collusio 22.06.2009, 04:13:34
Go to the top of the page
+Quote Post
Arsanael
post
Post #9





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 4.06.2009

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


Dzieki, działa (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) .
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 - 06:35