Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [SQL][PHP][HTML] Wyświetlenie danych sql w tabelce
Forum PHP.pl > Forum > Przedszkole
Proximus
Witam,
w bazie sql mam tabelkę logs a w niej osoba tresc czas, jak wyświetlać te dane w tabelce

|osoba|tresc|czas| ?

Teraz mam

Kod
$ktos = $db -> Execute("SELECT osoba, tresc, czas FROM logs");
    echo $ktos;


ale to wyświetla w ciągu i na początku pokazuje osoba, tresc, czas
krzysztof_kf
  1.  
  2. while ($rekord = mysql_fetch_assoc($ktos)){
  3. $osoba = $rekord['osoba'];
  4. $tresc = $rekord['tresc'];
  5. $czas = $rekord['czas'];
  6.  
  7. echo '<tr>'."\r\n";
  8. echo '<td>'.$osoba.'</td>'."\r\n";
  9. echo '<td>'.$tresc.'</td>'."\r\n";
  10. echo '<td>'.$czas.'</td>'."\r\n";
  11. echo '</tr>'."\r\n";
  12.  
  13. }
  14.  
Proximus
Cytat
Fatal error: Call to a member function Execute() on a non-object in /home/prox/domains/mirabar.eu/public_html/kartoteka.php on line 43


Kod
$ktos = $db -> Execute("SELECT osoba, tresc, czas FROM logs");

while ($rekord = mysql_fetch_assoc($ktos)){
$osoba = $rekord['osoba'];
$tresc = $rekord['tresc'];
$czas = $rekord['czas'];

echo '<tr>'."\r\n";
echo '<td>'.$osoba.'</td>'."\r\n";
echo '<td>'.$tresc.'</td>'."\r\n";
echo '<td>'.$czas.'</td>'."\r\n";
echo '</tr>'."\r\n";

}


mhm nie wiem co jest źle
krzysztof_kf
Połączyłeś się z bazą danych ? pokaż swój cały kod
Proximus
Na początku zapomniałem, usunąć jeden komentarz, ale po połączeniu się i tak jest błąd ten sam tylko w 68 linijce (ta sama)

  1. <?php
  2. /******************************************************
  3. * connection.php
  4. * konfiguracja połączenia z bazą danych
  5. ******************************************************/
  6.  
  7. function connection() {
  8. // serwer
  9. $mysql_server = "localhost";
  10. // admin
  11. $mysql_admin = "db_db";
  12. // hasło
  13. $mysql_pass = "haselko";
  14. // nazwa baza
  15. $mysql_db = "db_db";
  16. // nawiązujemy połączenie z serwerem MySQL
  17. @mysql_connect($mysql_server, $mysql_admin, $mysql_pass)
  18. or die('Brak połączenia z serwerem MySQL.');
  19. // łączymy się z bazą danych
  20. @mysql_select_db($mysql_db)
  21. or die('Błąd wyboru bazy danych.');
  22. }
  23.  
  24. ?>
  25.  
  26. <?php
  27. /**
  28.  * File functions:
  29.  * Kartoteka
  30.  *
  31.  * @name : kartoteka.php
  32.  * @copyright : (C) 2004,2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5
  33.  * @author : Proximus
  34.  * @version : 1.0
  35.  * @since : 04.08.2010
  36.  *
  37.  */
  38.  
  39. //
  40. //
  41. // This program is free software; you can redistribute it and/or modify
  42. // it under the terms of the GNU General Public License as published by
  43. // the Free Software Foundation; either version 2 of the License, or
  44. // (at your option) any later version.
  45. //
  46. // This program is distributed in the hope that it will be useful,
  47. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  48. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  49. // GNU General Public License for more details.
  50. //
  51. // You should have received a copy of the GNU General Public License
  52. // along with this program; if not, write to the Free Software
  53. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  54. //
  55. // $Id: kartoteka.php
  56.  
  57. $title = "Kartoteka";
  58. //require_once("includes/config.php");
  59.  
  60. /**
  61. * Get the localization for game
  62. */
  63. //require_once("languages/".$player -> lang."/kartoteka.php");
  64.  
  65. //$db -> Execute("SELECT * FROM lochylog");
  66.  
  67.  
  68. $ktos = $db -> Execute("SELECT osoba, tresc, czas FROM logs");
  69.  
  70. while ($rekord = mysql_fetch_assoc($ktos)){
  71. $osoba = $rekord['osoba'];
  72. $tresc = $rekord['tresc'];
  73. $czas = $rekord['czas'];
  74.  
  75. echo '<tr>'."\r\n";
  76. echo '<td>'.$osoba.'</td>'."\r\n";
  77. echo '<td>'.$tresc.'</td>'."\r\n";
  78. echo '<td>'.$czas.'</td>'."\r\n";
  79. echo '</tr>'."\r\n";
  80.  
  81. }
  82.  
  83.  
  84.  
  85. //$smarty -> display ('kartoteka.tpl');
  86.  
  87. //require_once("includes/foot.php");
  88. ?>
krzysztof_kf
Zmien z


  1.  
  2. $ktos = $db -> Execute("SELECT osoba, tresc, czas FROM logs");
  3.  



na :

  1. $zapytanie = 'SELECT osoba, tresc, czas FROM logs';
  2. $ktos = mysql_query($zapytanie);
  3.  
  4.  
Proximus
Cytat
Warning: mysql_query() [function.mysql-query]: Access denied for user 'prox'@'localhost' (using password: NIE) in /home/prox/domains/mirabar.eu/public_html/kartoteka.php on line 70

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/prox/domains/mirabar.eu/public_html/kartoteka.php on line 70


70 linijka to ta: $ktos = mysql_query($zapytanie);

zamieniłem teraz jeszcze

$rekord na $zapytanie
erix
Zanim się coś napisze w przedszkolu, obowiązkowo najpierw czyta kursy. Nie na odwrót.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.