Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL] Przekazanie danych z metody do formularza, [OOP]
jg44
post
Post #1





Grupa: Zarejestrowani
Postów: 122
Pomógł: 14
Dołączył: 14.07.2011
Skąd: Gliwice / Wrocław

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


Witam,
mam taką klasę:
  1. class Comment
  2. {
  3. public $name;
  4. public $message;
  5.  
  6. // (...)
  7.  
  8. public function setName($name)
  9. {
  10. $this->name = $name;
  11. }
  12.  
  13. public function setMessage($message)
  14. {
  15. $this->message = $message;
  16. }
  17.  
  18. public function printComments()
  19. {
  20. $r = mysql_query("SELECT * FROM ksiega WHERE ID='$this->id'")or die(mysql_error());
  21. while($l = mysql_fetch_array($r))
  22. {
  23. $name = $l['nazwa'];
  24. $message = $l['tresc'];
  25. }
  26. }
  27.  
  28. // (...)
  29.  
  30. }

Formularz:
  1. <form action="index.php" method="post">
  2. <input type="text" value="<?php ?>" name="name" /><br />
  3. <textarea cols="40" rows="6" name="message"><?php ?></textarea><br />
  4. <input type="submit" name="wyslany" value="Dodaj" />
  5. </form>

W jaki sposób przekazać zmienne $name i $message z metody printComments() do formularza?
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 Aktualny czas: 21.08.2025 - 01:27