Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Odczyt bazy danych w php
Jarek099
post 12.02.2010, 15:23:55
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 14.01.2010
Skąd: Słupsk

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


Witam mam taki kod :

  1. <?
  2. include 'dial.php'; // Połączenie mysql
  3.  
  4. $mysql = mysql_connect($host, $user, $password);
  5. mysql_select_db($baza, $mysql);
  6. $zapytanie= "SELECT * FROM `tabela`";
  7. $query=mysql_query($zapytanie);
  8. while($row=mysql_fetch_array($query)){
  9. $id = $row['0'];
  10. $imie = $row['1'];
  11. $nazwisko = $row['2'];
  12. $pseudo = $row['3'];
  13.  
  14. }
  15. <table width="800" border="1">
  16. <td width="50" align="center">id.</td> <td width="225" align="center">imie</td> <td width="225" align="center">nazwisko</td> <td width="200" align="center">pseudo</td>
  17. <tr>
  18. <td width="50" align="center">' . $id . '</td> <td width="225" align="center">' . $imie . '</td> <td width="225" align="center">' . $nazwisko . '</td> <td width="200" align="center">' . $pseudo . '</td>
  19. </tr>
  20. <tr>
  21. <td width="50" align="center">' . $id . '</td> <td width="225" align="center">' . $imie . '</td> <td width="225" align="center">' . $nazwisko . '</td> <td width="200" align="center">' . $pseudo . '</td>
  22. </tr>
  23. <tr>
  24. <td width="50" align="center">' . $id . '</td> <td width="225" align="center">' . $imie . '</td> <td width="225" align="center">' . $nazwisko . '</td> <td width="200" align="center">' . $pseudo . '</td>
  25. </tr>
  26. </table>');
  27. ?>


I pokazuje mi tylko ostanio dodaną 1 osobe w 3 tabelach.
A jak napisać by pokazywało 3 ostatnich użytkowników ?
Bo sie męcze i męcze tongue.gif aż ksiązke zamówiłem ale dojdzie za tydzień gdzieś :|
Pomożecie ?

Ten post edytował Jarek099 12.02.2010, 15:24:58
Go to the top of the page
+Quote Post
lutador
post 12.02.2010, 15:27:49
Post #2





Grupa: Zarejestrowani
Postów: 183
Pomógł: 3
Dołączył: 5.03.2007
Skąd: Opole

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


Tabela musi byc w zawarta w petli miedzy { .. }

Ten post edytował lutador 12.02.2010, 15:28:42
Go to the top of the page
+Quote Post
rytek
post 12.02.2010, 15:31:02
Post #3





Grupa: Zarejestrowani
Postów: 63
Pomógł: 14
Dołączył: 21.01.2009
Skąd: Mszczonów

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


  1. <?
  2. include 'dial.php'; // Połączenie mysql
  3.  
  4. $mysql = mysql_connect($host, $user, $password);
  5. mysql_select_db($baza, $mysql);
  6. $zapytanie= "SELECT * FROM `tabela`";
  7. $query=mysql_query($zapytanie);
  8.  
  9. echo'<table width="800" border="1">
  10. <tr>
  11. <td width="50" align="center">id.</td><td width="225" align="center">imie</td> <td width="225" align="center">nazwisko</td><td width="200" align="center">pseudo</td></tr>';
  12.  
  13. while($row=mysql_fetch_array($query)){
  14. $id = $row['0'];
  15. $imie = $row['1'];
  16. $nazwisko = $row['2'];
  17. $pseudo = $row['3'];
  18.  
  19. echo'<tr>
  20. <td width="50" align="center">' . $id . '</td> <td width="225" align="center">' . $imie . '</td> <td width="225" align="center">' . $nazwisko . '</td> <td width="200" align="center">' . $pseudo . '</td>
  21. </tr>
  22. ';
  23. }
  24. echo"</table>";
  25. ?>
Go to the top of the page
+Quote Post
Jarek099
post 12.02.2010, 15:51:09
Post #4





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 14.01.2010
Skąd: Słupsk

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


Dzięki wielkie exclamation.gif!
Go to the top of the page
+Quote Post

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 - 09:06