Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> System NEWS'ów na MySQL, problem z pętla ? ......
peter001
post 22.05.2005, 09:49:00
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 26.12.2003

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


mam następującą funkcje odpowiedzialną za wyświetlanie NEWS'ów

  1. <?php
  2. function news()
  3.  {
  4. $aDBLink = @mysql_connect( &#092;"localhost\", \"root\", \"aresik\" );
  5. mysql_select_db(&#092;"GBA\");
  6.  
  7.  
  8. $aSQL = &#092;"select numer from ilosc where nazwa='NEWS'\";
  9. $aQResult = mysql_query( $aSQL, $aDBLink );
  10. while ( $aRow = mysql_fetch_array( $aQResult ) )
  11. {
  12. $liczba = $aRow[&#092;"numer\"];
  13. }; 
  14. $x = $liczba;
  15. do
  16. {
  17. $aSQL = &#092;"select * from news where numer= $x \";
  18. $aQResult = mysql_query( $aSQL, $aDBLink );
  19. while ( $aRow = mysql_fetch_array( $aQResult ) )
  20. {
  21. $tytul = $aRow[&#092;"tytul\"];
  22. $data_dodania = $aRow[&#092;"data_dodania\"];
  23. $tresc = $aRow[&#092;"tresc\"];
  24. $autor = $aRow[&#092;"autor\"];
  25. };
  26. $x = $x - 1 ;
  27. echo (&#092;"
  28.  
  29. <TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0'>
  30.  <TR>
  31. <TD>
  32.  <TD bgcolor='blue' align='left' valign='top' width='400'>
  33.  <Font color='white'>
  34.  $tytul
  35.  </Font>
  36. </TD>
  37. <TD>
  38.  <TD bgcolor='blue' align='right' valign='top' width='100'>
  39.  <Font color='white'>
  40.  $data_dodania
  41.  </Font>
  42. </TD>
  43.  </TR>
  44.  <TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0'>
  45. <TR>
  46.  <TD>
  47. <TD bgcolor='lightblue' align='left' valign='top' width='500'>
  48. $tresc
  49.  </TD>
  50. </TR>
  51. <TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0'>
  52.  <TR>
  53. <TD>
  54.  <TD bgcolor='blue' align='right' valign='top' width='500'>
  55.  <FONT color='white'>
  56.  $autor
  57.  </FONT>
  58. </TD>
  59.  </TR>
  60.  <TR>
  61. <TD>
  62.  <TD height='100'>
  63. </TD>
  64.  </TR>
  65. </TABLE>
  66. &#092;");
  67. } while ($x < 1 );
  68. mysql_close($aDBLink); 
  69.  }
  70.  
  71. ?>


Mimo, że na koniec wykonania funkcjii zmienna $x wynosi 2 petla się kończy i wyświetla się tylko 1 NEWS . Jaki głupi błąd znowu zrobiłem ? biggrin.gif
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: 19.07.2025 - 12:48