Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Wyciąganie danych z dwóch tabel + języki
b_chmura
post
Post #1





Grupa: Zarejestrowani
Postów: 813
Pomógł: 34
Dołączył: 18.03.2007
Skąd: o stamtąd

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


Witam

Nie wiem do końca jak zadać pytanie... więc zacznę od kodu.

  1. Table #1
  2.  
  3. id|url|time


  1. Table #2
  2. id_parent|id_lang|name


Jakie rozwiązania polecicie by po zapytaniu (zapytaniach?) uzyskać taką tablice:

  1. [0] = array(
  2. [id] = 1
  3. [url] = 'http://google.pl'
  4. [name] = array(
  5. [id_lang_1 (lub 0)] = 'Nazwa w języku PL'
  6. [id_lang_2 (lub 1)] = 'Nazwa w języku EN'
  7. [id_lang_? (lub ?)] = 'Nazwa w języku ?'
  8. (...)
  9. );
  10. )
  11. [1] = array(
  12. ...
  13. )
  14.  
  15. ...


Zdaje sobie sprawę, że jest to trochę nie zrozumiałem... w razie wypadku odpowiem na każde pytanie.

Pozdrawiam
Chmura B.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
b_chmura
post
Post #2





Grupa: Zarejestrowani
Postów: 813
Pomógł: 34
Dołączył: 18.03.2007
Skąd: o stamtąd

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


Umiem sobie poradzić z Twoim kodem, jest w porządku.
Teraz kombinuje jak to zautomatyzować żebym nie musiał podawać jakie pole chce połączyć (zawsze będzie to pole które występuje kilka razy i ma inną wartość.

Dla przykład:

żeby z takiej tablicy:
  1.  
  2. (
  3. [0] => Array
  4. (
  5. [id] => 1
  6. [prefix] => site
  7. [url] => <a href="http://www.google.pl/" target="_blank">http://www.google.pl/</a>
  8. [id_parent] => 1
  9. [id_lang] => 1
  10. [name] => Google in PL
  11. )
  12.  
  13. [1] => Array
  14. (
  15. [id] => 1
  16. [prefix] => site
  17. [url] => <a href="http://www.google.pl/" target="_blank">http://www.google.pl/</a>
  18. [id_parent] => 1
  19. [id_lang] => 2
  20. [name] => Google in EN
  21. )
  22.  
  23. [2] => Array
  24. (
  25. [id] => 2
  26. [prefix] => blog
  27. [url] => <a href="http://bing.pl" target="_blank">http://bing.pl</a>
  28. [id_parent] => 2
  29. [id_lang] => 1
  30. [name] => Bing in PL
  31. )
  32.  
  33. [3] => Array
  34. (
  35. [id] => 2
  36. [prefix] => blog
  37. [url] => <a href="http://bing.pl" target="_blank">http://bing.pl</a>
  38. [id_parent] => 2
  39. [id_lang] => 2
  40. [name] => Bing in EN
  41. )
  42.  
  43. )


Zrobić taką:

  1. (
  2. [0] => Array
  3. (
  4. [id] => 1
  5. [prefix] => site
  6. [url] => <a href="http://www.google.pl/" target="_blank">http://www.google.pl/</a>
  7. [id_parent] => 1
  8. [id_lang] => Array(
  9. [1] = 1
  10. [2] = 2
  11. )
  12. [name] => Array(
  13. [1] = Google in PL
  14. [2] = Google in EN
  15. )
  16. )
  17.  
  18. [1] => Array
  19. (
  20. [id] => 2
  21. [prefix] => blog
  22. [url] => <a href="http://bing.pl" target="_blank">http://bing.pl</a>
  23. [id_parent] => 2
  24. [id_lang] => Array(
  25. [1] = 1
  26. [2] = 2
  27. )
  28. [name] => Array(
  29. [1] = Bing in PL
  30. [2] = Bing in EN
  31. )
  32. )
  33.  
  34. )
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: 9.10.2025 - 14:50