Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL] Dane z 2 tabel
Micchaleq
post
Post #1





Grupa: Zarejestrowani
Postów: 186
Pomógł: 4
Dołączył: 13.10.2009

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


Witam serdecznie,

Mam 2 tabele :

1 users :
-user_id
-username
-user_password

2. user_groups
-group_id
-user_id

chcę wyświetlić wszystkie group_id dla danego użytkownika:

Próbowałem tak :
  1. $sql = "SELECT u.username, u.user_password, ug.user_id, g.group_id from ".USERS_TABLE." u, left join ".USERS_GROUPS_TABLE." g WHERE u.username = '".$username."' AND u.user_id = g.user_id";


Ktoś pomoże?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
gorden
post
Post #2





Grupa: Zarejestrowani
Postów: 486
Pomógł: 101
Dołączył: 27.06.2010

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


  1. $id_uzytkownika = 1;
  2. $query = mysql_query("SELECT group_id FROM user_groups WHERE user_id LIKE '$id_uzytkownika'");
  3. while($result = mysql_fetch_row($query)) echo $result[0];


Ten post edytował gorden 11.05.2011, 14:08:16
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: 16.10.2025 - 05:05