Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> wyswietlanei z funkcji w zlym miejscu
remik09
post 8.02.2008, 11:55:24
Post #1





Grupa: Zarejestrowani
Postów: 102
Pomógł: 10
Dołączył: 25.12.2005
Skąd: Ruda Śląska

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


mam kod
  1. <?php
  2. function tnij ($cos_do_obciecia, $ile_znakow) {
  3. if (strlen($cos_do_obciecia) > $ile_znakow) {
  4. $obciete = substr($cos_do_obciecia,0,$ile_znakow);
  5. $tresc = $obciete.'...';
  6. } else {
  7. $tresc = $cos_do_obciecia;
  8. }
  9. print $tresc;
  10. };
  11.  
  12. function wyswietl_news ($tytul, $data, $tresc) {
  13. print '
  14. <a href="#"><strong>'.$tytul.'</strong></a> Data dodania: '.$data.'</a><br />
  15. <small>'.$tresc.'</small><br /><br />
  16. ';
  17. };
  18. $wynik = mysql_query("SELECT * FROM news ORDER by id DESC")
  19. or die('B��d zapytania');
  20. while($r = mysql_fetch_assoc($wynik)) {
  21. $zdanie = $r['tresc'];
  22. $wyswietl = tnij($zdanie, 300);
  23.  
  24. print wyswietl_news($r['tytul'], $r['data'], $wyswietl);
  25. }
  26. ?>


i wychodzi z tego

  1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur lectus leo, venenatis sed, rhoncus vitae, tincidunt in, lacus. Aliquam erat volutpat. Ut nunc. Nulla non nisi quis eros pellentesque hendrerit. Mauris sollicitudin. Nulla nonummy tellus ultricies libero. Nulla at arcu in felis conse...
  2. <a href="#"><strong>Lorem ipsum</strong></a> Data dodania: 11:17 08-2-2008</a><br />
  3. <small></small><br /><br />


Czyli tresc jest w trszke innym miejscu niz ma, ma ktos pomysl dlaczego ?


--------------------
moj blog z glupotami
darmowe mp3

workstation: zendstudio 5.5.0 | EditPlus 3 | PHP/4.3.9 |
Go to the top of the page
+Quote Post
nowotny
post 8.02.2008, 12:03:26
Post #2





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

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


No bo tam ją wyświetlasz:
  1. <?php
  2. print $tresc;
  3. ?>

zamień sobie "print" na "return"...
Go to the top of the page
+Quote Post
remik09
post 8.02.2008, 12:05:39
Post #3





Grupa: Zarejestrowani
Postów: 102
Pomógł: 10
Dołączył: 25.12.2005
Skąd: Ruda Śląska

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


prosta pomylka ale dziala teraz jak nalezy, dzieki


--------------------
moj blog z glupotami
darmowe mp3

workstation: zendstudio 5.5.0 | EditPlus 3 | PHP/4.3.9 |
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.07.2025 - 15:01