Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Pętla zwraca o 1 wynik za mało
o2w5n778
post 5.01.2012, 17:04:34
Post #1





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 10.12.2009

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


Witam!
Mam taką oto pętle:
  1. <?php
  2.  
  3. $query = mysql_query("SELECT * FROM jc_news ORDER BY news_order DESC");
  4. $nr = mysql_fetch_array($query);
  5. echo('<div id="panel1"><a href="index.php?id=news&add=news">Dodaj newsa</a></div>');
  6. echo('<div id="panel2">');
  7. echo('<table>');
  8. echo('<tr>');
  9. echo('<td class="name_t">Nazwa</td>');
  10. echo('<td class="delete_t">Usuń</td>');
  11. echo('<td class="order_t">Porządek</td>');
  12. echo('</tr>');
  13. while($show = mysql_fetch_array($query)){
  14. echo('<tr>');
  15. echo('<td class="name_s"><a href="#">'.$show['news_name'].'</a></td>');
  16. echo('<td class="delete_s"><a href="#">'.$show['news_name'].'</a></td>');
  17. echo('<td class="order_s">'.$show['news_name'].'</td>');
  18. echo('</tr>');
  19. }
  20. echo('</table>');
  21. echo('</div>');
  22.  
  23.  
  24.  
  25.  
  26. ?>

Niestety zwraca mi o 1 wynik za mało, w czym problem?

zamiast
  1. $nr = mysql_num_rows($query);

dałem
  1. $nr = mysql_fetch_array($query);


już sobie poradziłem

Ten post edytował o2w5n778 5.01.2012, 17:04:59


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 07:18