Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Odczyt bazy danych w php
Jarek099
post
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 (IMG:style_emoticons/default/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
 
Start new topic
Odpowiedzi
rytek
post
Post #2





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

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: 14.10.2025 - 16:12