Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MYSql] [PHP] wyświetla jeden rekord zamiast wszystkich....
mathevs
post
Post #1





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 5.11.2012

Ostrzeżenie: (10%)
X----


Witam wszystkich (IMG:style_emoticons/default/tongue.gif)
Jestem nowy i dopiero sie ucze php i mysql
a więc chodzi o to ze ten skrypt wyświetla mi tylko jeden rekord zamiast wszystkich wybranych...
Prosze o pomoc z góry dzieki :0

(wyswietlać wyświetla dobrze tylko że wyświetla jeden rekord)

  1.  
  2. $pid = $_GET['id'];
  3.  
  4. $query = safe_sql("SELECT * FROM player.guild WHERE name='$pid'");
  5.  
  6. if(mysql_num_rows($query)==1) {
  7.  
  8. $g = mysql_fetch_assoc($query);
  9.  
  10.  
  11. $gm = mysql_fetch_assoc(safe_sql("SELECT * FROM player.guild_member WHERE guild_id='".$g['id']."'"));
  12.  
  13. $gm2 = mysql_fetch_assoc(safe_sql("SELECT * FROM player.player WHERE id='".$gm['pid']."'"));
  14.  
  15. $members_guild = ''.$gm2['name'].'<br>';
  16.  
  17. echo $members_guild;
  18.  
  19. i reszta...


Ten post edytował mathevs 5.11.2012, 00:24:34
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
skowron-line
post
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


Aby wyświetlić wszystkie rekordy musisz użyć pętli
mysql_fetch_array.

I żeby nie było, używaj PDO.
Go to the top of the page
+Quote Post
mathevs
post
Post #3





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 5.11.2012

Ostrzeżenie: (10%)
X----


no dobra zrobilem tak jak chciales ..
ale teraz wgl nic nie wyswietla (IMG:style_emoticons/default/tongue.gif)

  1. $gm = mysql_query("SELECT * FROM player.guild_member WHERE guild_id='".$g['id']."'");
  2. while ($gm_1 = mysql_fetch_array($gm)) {
  3.  
  4. $gm2 = mysql_query("SELECT * FROM player.player WHERE id='".$gm['pid']."'");
  5.  
  6. while ($gm_2 = mysql_fetch_array($gm2)) {
  7.  
  8. $members_guild = index.php?load=gracz&id='.$gm_2['name'].'">'.$gm_2['name'].'</a><br>';
  9. }
  10.  
  11. }
Go to the top of the page
+Quote Post
skowron-line
post
Post #4





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


  1. $gm['pid']

tylko
  1. $gm_1
Go to the top of the page
+Quote Post
mathevs
post
Post #5





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 5.11.2012

Ostrzeżenie: (10%)
X----


  1. $gm_1['pid']

musi być bo pid z tabeli guild_members to odniesienie gracza w tabeli player.player


teraz ten kod wygląda tak

  1. $pid = $_GET['id'];
  2.  
  3. $query = safe_sql("SELECT * FROM player.guild WHERE name='$pid'");
  4.  
  5. if(mysql_num_rows($query)==1) {
  6.  
  7. $g = mysql_fetch_assoc($query);
  8.  
  9.  
  10.  
  11. $gm = mysql_query("SELECT * FROM player.guild_member WHERE guild_id='".$g['id']."'");
  12. while ($gm_1 = mysql_fetch_array($gm)) {
  13.  
  14. $gm2 = mysql_query("SELECT * FROM player.player WHERE id='".$gm_1['pid']."'");
  15.  
  16. while ($gm_2 = mysql_fetch_array($gm2)) {
  17.  
  18. $members_guild = '<a href="index.php?load=gracz&id='.$gm_2['name'].'">'.$gm_2['name'].'</a><br>';
  19. }
  20.  
  21. }


i znowu wyswietla jeden rekord ale inny (IMG:style_emoticons/default/tongue.gif)

Ten post edytował mathevs 5.11.2012, 01:16:40
Go to the top of the page
+Quote Post
skowron-line
post
Post #6





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


A czy zapytania zwracają więcej niż jeden rekord (IMG:style_emoticons/default/questionmark.gif) Wyświetl sobie je na ekran i wklej do PMA
Go to the top of the page
+Quote Post
mathevs
post
Post #7





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 5.11.2012

Ostrzeżenie: (10%)
X----


nie tylko jedno wyswietla :/
wyświetlam w ten sposób

  1. echo $members_guild;


a napewno jest więcej niz 3 rekordy w bazie ...

dobra poradziłem sobie dzięki (IMG:style_emoticons/default/tongue.gif)


DO ZAMKNIĘCIA!


Ten post edytował mathevs 5.11.2012, 02:18:32
Go to the top of the page
+Quote Post

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: 24.12.2025 - 03:20