Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] 1 pętla 2 tabele do obsługi
Lejto
post
Post #1





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 48
Dołączył: 23.05.2007

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


Wyświetlam zdjęcia z galerii i chce pod każdym zdjęciem mieć ostatni dodany komentarz i z tym mi nie wychodzi. Dodać jeszcze 1 pętle czy jak? Kod mam taki
  1. <?
  2. $sql =
  3.            $db->query('select obraz,data_dodania,id,opis,wyswietlen from galeria order by id desc LIMIT '.$strona.', '.$ile_na_strone.'');
  4.            $rows = $sql->num_rows;
  5.        $q = $db->query('select komm,data,nick from galeria_komentarze order by id desc limit 1');
  6.        $r = $q->num_rows;
  7.  
  8.        
  9.        for($i=0; $i < $rows; $i++)
  10.        {
  11.           $row = $sql->fetch_array();
  12.           $r = $q->fetch_array();
  13.          
  14.           $data = substr($row['data_dodania'], 0,8);
  15.           ?>
  16.           <div id="gal2" class="obraz">
  17.    
  18.                            <dl><dd class="img">
  19.                            <a href="foto/<?=$row['id']; ?>/" title="<?=$row['opis'];?>">
  20.                            <img src="miniatury/<?=$row['obraz'];?>"  align="center">
  21.                            </a>
  22.                            </dd></dl>    
  23.                            <div style="text-align:center;">&raquo; Data dodania: <?=$data; ?></div>
  24.                            <div style="text-align:center;">&raquo; Wyświetleń: <?=$row['wyswietlen']; ?></div>
  25.                            <div style="text-align:center;">&raquo; Dodał(a): <?=$row['nick']; ?></div>
  26.                            
  27.                            
  28.                            <div class="comment_top"></div>
  29.                            <div class="comment" style="text-align:left;">
  30.                            <p class="comment"><?=$r[komm]; ?></p>
  31.                            </div>
  32.                            <div class="comment_bottom"></div>
  33.                            <p class="comment"><?=$r[nick]; ?></p>
  34.                            <p class="datetime" style="text-align:left;"><?=$r[data]; ?></p>
  35.                            </div>
  36.                            <?
  37.                            
  38.        }


Ten post edytował Lejto 16.06.2009, 22:21:51
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: 24.08.2025 - 16:07