Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][PHP][MySQL]Proste(?) przerobienie skryptu msql na 2 tabele
fardbleecker
post 24.12.2012, 21:57:28
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 24.12.2012

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


Witam, mam problem. Jestem totalnie obcy w php jak i mysql.
Potrzebuje przerobienia skryptu, który pobierał nazwe i stan konta, na taki który pobiera to z 2 różnych tabel. W jednej jest nazwa i id, w drugiej jest id i balans.

Stary skrypt
  1. <html>
  2. <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
  3. </html>
  4.  
  5. <?php
  6. require ('config.php');
  7. //Connects to the database and the specified table.
  8. $handle = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die($connect_error);
  9. mysql_select_db($mysql_db, $handle) or die($connect_error);
  10. $sql = mysql_query('SELECT username, balance FROM '.$mysql_table.' ORDER BY balance DESC');
  11. //Define first rank.
  12. $rank = 1;
  13. ?>
  14.  
  15. <center>
  16. <h1><u>iConomy Player Stats</u></h1>
  17. <table border="0" cellpadding="3" cellspacing="10" id="minimalist">
  18. <tr>
  19. <td width="50"><strong>Avatar</strong></td>
  20. <td width="30"><strong>Username</strong></td>
  21. <td width="30"><strong>Wealth</strong></td>
  22. <td width="30"><strong>Rank</strong></td>
  23. </tr>
  24. <?php
  25. while($data = mysql_fetch_assoc($sql)) {
  26. //Loops data and displays it in a table.
  27. echo '<tr>';
  28. echo '<td><strong>'.'<img src=http://minotar.net/avatar/'.$data['id'].'/50.png />'.'</strong></td>';
  29. echo '<td><strong>'.$data['username'].'</strong></td>';
  30. echo '<td><strong>'.$data["balance"].'</strong></td>';
  31. echo '<td><strong>'.$rank++.'</strong></td></tr>';
  32. }
  33. ?>
  34. <?//Awkward ?>
  35. </table></center>


w config.php są dane oraz
  1. if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass)||!mysql_select_db($mysql_db)) {
  2. die($connect_error);


Z góry dziękuje!

Ten post edytował fardbleecker 24.12.2012, 22:05:48
Go to the top of the page
+Quote Post

Posty w temacie


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: 14.08.2025 - 15:50