Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]Pobieranie danych z bazy, i wyświetlanie w polu textarea.
Ennioasofaroman
post 22.05.2010, 09:39:59
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 21.05.2010

Ostrzeżenie: (10%)
X----


Witam, mam problem...

Otóż ostatnio tworzyłem system profili do mojej strony, i zrobiłem do niego system bbcode. BBcode dobrze działa, ponieważ wcześniej go testowałem, ale nie działa wyświetlanie tekstu pobieranego z bazy, przefiltrowanego funkcją bbcode w polu textarea... Tak wygląda mój kod:

  1. <br><b><h3>Edycja profilu</h3></b>
  2. <form action="aktualizuj.php" method="post">
  3. <textarea name="profil" cols="10" rows="10" style="background-color: #E3DEE1; width: 60%; height: 110%; border-style: dashed; border-color: #000000"><?php
  4. require('conn.php');
  5.  
  6. $login=$_SESSION['login'];
  7.  
  8.  
  9. $wynik = mysql_query("SELECT profil FROM user WHERE login='$login'")
  10. or die('Błąd zapytania');
  11. while($r = mysql_fetch_assoc($wynik)) {
  12.  
  13.  
  14. $tekst=$r['nick'];
  15.  
  16.  
  17.  
  18.  
  19.  
  20. function bbcode($tekst) { //Funkcja
  21. $tekst = htmlspecialchars($tekst); //Tagi HTML
  22. $tekst = preg_replace("#\[b\](.*?)\[/b\]#si", "<b>\\1</b>", $tekst); //Pogrubienie
  23. $tekst = preg_replace("#\[i\](.*?)\[/i\]#si", "<i>\\1</i>", $tekst); //Pochylenie
  24. $tekst = preg_replace("#\[u\](.*?)\[/u\]#si", "<u>\\1</u>", $tekst); //Podksreślenie
  25. $tekst = preg_replace("#\[color=(http://)?(.*?)\](.*?)\[/color\]#si", "<span style=\"color: \\2\">\\3</span>", $tekst); //Kolor
  26. $tekst = preg_replace("#\[size=(http://)?(.*?)\](.*?)\[/size\]#si", "<span style=\"font-size: \\2\">\\3</span>", $tekst); //Rozmiar
  27. $tekst = preg_replace("#\[url\](.*?)\[/url\]#si", "<a href=\"\\1\">\\1</a>", $tekst); //Link
  28. $tekst = preg_replace("#\[url=(http://)?(.*?)\](.*?)\[/url\]#si", "<a href=\"\\2;\">\\3</a>", $tekst); //Link
  29. $tekst = preg_replace("#\[img\](.*?)\[/img\]#si", "<img src=\"\\1\">", $tekst); //Obrazek
  30. $tekst = preg_replace("#\[img=(http://)?(.*?)\](.*?)\[/img\]#si", "<img src=\"\\2\" alt=\"\\3\">", $tekst); //Obrazek
  31. $tekst = preg_replace("#\[quot\](.*?)\[/quot\]#si", "<blockquot>\\1</blockquot>", $tekst); //Cytat
  32. $tekst = preg_replace("#\[code\](.*?)\[/code\]#si", "<pre>\\1</pre>", $tekst); //Kod
  33. $tekst = nl2br($tekst); //Następna linijka
  34. return $tekst; //Wyjście
  35. }
  36. $result = bbcode("$tekst"); //Użycie funkcji
  37.  
  38.  
  39.  
  40.  
  41.  
  42. echo bbcode("$result");
  43. }
  44.  
  45.  
  46. ?>
  47.  
  48.  
  49.  
  50.  
  51. </textarea>
  52. <br>
  53.  
  54. <input type="submit" value="Zmień" />


Mam nadzieję, że mi ktoś pomoże... Pozdrawiam
Powód edycji: [strife]: Przenoszę na Przedszkole
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
Kshyhoo
post 22.05.2010, 09:44:39
Post #2





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Wcale nie wyświetla, czy nie ma BBcode?


--------------------
Go to the top of the page
+Quote Post
Ennioasofaroman
post 22.05.2010, 09:45:10
Post #3





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 21.05.2010

Ostrzeżenie: (10%)
X----


Nie wyświetla w ogóle tekstu pobieranego z bazy... ;<
Go to the top of the page
+Quote Post
Kshyhoo
post 22.05.2010, 09:48:04
Post #4





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Przykład:
  1. <textarea cols="80" id="editor1" name="editor1" rows="10"><?php echo $tresc; ?></textarea>


--------------------
Go to the top of the page
+Quote Post
Ennioasofaroman
post 22.05.2010, 10:07:44
Post #5





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 21.05.2010

Ostrzeżenie: (10%)
X----


Ale jak zrobić, żeby wyświetlało dane pobrane z bazy, przefiltrowane tą funkcją?
Go to the top of the page
+Quote Post
Kshyhoo
post 22.05.2010, 10:53:04
Post #6





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Pobierz z bazy, przefiltruj, dołącz do textarea...


--------------------
Go to the top of the page
+Quote Post
Ennioasofaroman
post 22.05.2010, 12:33:16
Post #7





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 21.05.2010

Ostrzeżenie: (10%)
X----


Boże... przecież tak robiłem, i pisałem, że to nie działa... Czytanie ze zrozumieniem się kłania.
Go to the top of the page
+Quote Post
Kshyhoo
post 22.05.2010, 12:48:31
Post #8





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Kłania się, kłania - czytanie regulaminu forum ze zrozumieniem. To forum php a nie wróżbitów... Masz problem z kodem, który Ci nie działa, to go wklej - jak i wyniki działania print_r, tudzież wyświetlone błędy...


--------------------
Go to the top of the page
+Quote Post
marcio
post 22.05.2010, 13:20:47
Post #9





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Po pierwsze pobierasz kolumne profil:
  1. $wynik = mysql_query("SELECT profil FROM user WHERE login='$login'")

A potem w while() masz takie cos:
  1. $tekst=$r['nick'];

Imho bezsens.
Po czym robisz nastepny bezsens:
  1. $result = bbcode("$tekst"); //Użycie funkcji
  2.  
  3. echo bbcode("$result");


btw: w ogole sesji nie filtrujesz :]


Ten post edytował marcio 22.05.2010, 13:22:14


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
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: 14.08.2025 - 09:09