Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SQL]Złe wartości w łączeniu rekordów 2 tabel
eurosoft
post
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 5.11.2010

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


Proszę o pomoc w kodzie, po dodaniu warunku WHERE $tabela.nr_obw='{$_SESSION['nr_obw']}' rekordy się mieszają

  1. $sql = "SELECT COUNT(*) FROM $tabela WHERE nr_obw='{$_SESSION['nr_obw']}'";
  2. $result = mysql_query($sql) OR die('Queryproblem: ' . mysql_error());
  3. $ilePozycji = mysql_result($result, 0);
  4. mysql_free_result($result);
  5.  
  6. $sql = "SELECT * FROM $tabela WHERE nr_obw='{$_SESSION['nr_obw']}' LIMIT $from, $ileNaStronie";
  7. $result = mysql_query($sql) OR die('Queryproblem: '.mysql_error());
  8. $zlicz = mysql_num_rows($result);
  9.  
  10. $sql1 = "SELECT
  11. $tabela.id_book,
  12. $tabela.imie_nazwisko,
  13. $tabela.start_pol,
  14. $tabela1.animals,
  15. $tabela1.animals1,
  16. $tabela1.animals2,
  17. $tabela1.ilosc,
  18. $tabela1.ilosc1,
  19. $tabela1.ilosc2,
  20. $tabela1.ilosc_shot,
  21. $tabela1.login
  22. FROM $tabela LEFT JOIN shot ON $tabela.id_book=$tabela1.id_book WHERE $tabela.nr_obw='{$_SESSION['nr_obw']}' and $tabela.id_book>$from";
  23. $result1 = mysql_query($sql1) OR die('Queryproblem: '.mysql_error());
  24.  
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Smertius
post
Post #2





Grupa: Zarejestrowani
Postów: 156
Pomógł: 31
Dołączył: 23.02.2009
Skąd: Sanok

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


Co rozumiesz pod pojęciem "rekordy się mieszają"?

Do sortowania służy ORDER BY
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: 6.10.2025 - 21:56