Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Rotator banerów, odśwież co 20 sek.
-Garbacz-
post 6.01.2006, 11:48:46
Post #1





Goście







Witam, czy można stworzyć prosty rotator banerów z częstotliwością odświeżania 20 sekunk??

Czyli co 20 sekund jest nowy baner??

Czy można to zrobić bez bazy mysql??

samo czyste php??
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 14)
php programmer
post 6.01.2006, 11:54:54
Post #2





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 5
Dołączył: 8.11.2004
Skąd: trójmiasto

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


zamiast bazy mozna użyć plików do zapamietywania informacji o banerach np gdzie jest plik swf czy jpg danego banera, do zmiany banera co x sekund mozna użyć funkcji setInterval

Ten post edytował php programmer 6.01.2006, 11:55:29
Go to the top of the page
+Quote Post
strife
post 6.01.2006, 12:12:57
Post #3





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


@php programmer - setInterval dotyczy php ? od kiedy ? tongue.gif

Mały zarys
  1. <?php
  2. // rotator banerow :]
  3.  
  4. $array[1] = 'bannerek 1';
  5. $array[2] = 'bannerek 2';
  6. $array[3] = 'bannerek 3';
  7. $array[4] = 'bannerek 4';
  8. $array[5] = 'bannerek 5';
  9.  
  10. $czas = 5; // 5 sekund
  11.  
  12. $url = (int)$_GET['x'];
  13.  
  14. if ( empty ( $url ) or $url >= count ( $array ) )
  15. {
  16. $url = 1;
  17. }
  18. else
  19. {
  20. $url++;
  21. }
  22. echo $array[$url];
  23.  
  24. header( "Refresh: " . $czas . "; URL=?x=" . $url );
  25.  
  26. ?>


Mam nadzieję, że o to chodziło ? tongue.gif


--------------------
Go to the top of the page
+Quote Post
php programmer
post 6.01.2006, 12:15:58
Post #4





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 5
Dołączył: 8.11.2004
Skąd: trójmiasto

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


Cytat
@php programmer - setInterval dotyczy php ? od kiedy ?


Nie dotyczy, ale kto powiedział, że nie można użyć JS?
JS najlepiej sie chyba nadaje, bo nie trzeba wtedy przeładowywać strony.
Go to the top of the page
+Quote Post
-Guest-
post 6.01.2006, 12:18:52
Post #5





Goście







a jest taki gotowy skrypt php, bo ja się niestety na tym nie znam a bardzo tego potrzebuję....

byłbym bardzo niezmiernie wdzięczby jakby ktoś podaj taki skrypt albo namiaryt na niego..
Go to the top of the page
+Quote Post
strife
post 6.01.2006, 12:20:02
Post #6





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


Cytat(php programmer @ 2006-01-06 12:15:58)
Nie dotyczy, ale kto powiedział, że nie można użyć JS?
JS najlepiej sie chyba nadaje, bo nie trzeba wtedy przeładowywać strony.

Może fakt, że temat jest na forum dotyczącym php i to że autor zaznacza
Cytat
samo czyste php??


Ale wiesz, nie wiem tongue.gif

EOT.


--------------------
Go to the top of the page
+Quote Post
-Guest-
post 6.01.2006, 12:20:11
Post #7





Goście







Przepraszam, za dwa pod sobą posty, dziękuję!! Bardzo dziekuję!!
Go to the top of the page
+Quote Post
php programmer
post 6.01.2006, 12:21:45
Post #8





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 5
Dołączył: 8.11.2004
Skąd: trójmiasto

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


Cytat
samo czyste php??

To chyba dotyczyło, że czyste php w sensie,że bez MySQL,
tak mi sie wydaje

Ten post edytował php programmer 6.01.2006, 12:22:59
Go to the top of the page
+Quote Post
-Guest-
post 6.01.2006, 12:23:25
Post #9





Goście







mam mały problem, jezeli mam banery napisane w JV to wyskjakuje błąd właśnie na tym kodzie.

baner zaczyna się <script> i kończy </script>
Go to the top of the page
+Quote Post
strife
post 6.01.2006, 12:29:31
Post #10





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


Cytat(Guest @ 2006-01-06 12:23:25)
mam mały problem, jezeli mam banery napisane w JV to wyskjakuje błąd właśnie na tym kodzie.

baner zaczyna się <script> i kończy </script>

I mamy się domyślić co to jest za błąd? Może pokażesz?


--------------------
Go to the top of the page
+Quote Post
-Guest-
post 6.01.2006, 12:32:30
Post #11





Goście







Błąd

Kod
Parse error: parse error in c:\usr\krasnal\www\eurobarre\ebay.php on line 58



KOD:

  1. <?php
  2. // rotator banerow
  3.  
  4. $array[1] = '<script language="javascript">
  5. var uri = 'http://imppl.tradedoubler.com/imp/img/16173458/1184633?' + new String (Math.random()).substring (2, 11);
  6. document.write('<a href="http://clk.tradedoubler.com/click?p=39590&a=1184633&g=16173458" target="_blank"><img src="'+uri+'" border=0></a>');
  7. </script>';
  8.  
  9. $array[2] = '<script language="javascript">
  10. var uri = 'http://imppl.tradedoubler.com/imp/img/1128784/1184633?' + new String (Math.random()).substring (2, 11);
  11. document.write('<a href="http://clk.tradedoubler.com/click?p=22131&a=1184633&g=1128784" target="_blank"><img src="'+uri+'" border=0></a>');
  12. </script>';
  13.  
  14. $array[3] = 'bannerek 3';
  15. $array[4] = 'bannerek 4';
  16. $array[5] = 'bannerek 5';
  17.  
  18. $czas = 5; // 5 sekund
  19.  
  20. $url = (int)$_GET['x'];
  21.  
  22. if ( empty ( $url ) or $url >= count ( $array ) )
  23. {
  24. $url = 1;
  25. }
  26. else
  27. {
  28. $url++;
  29. }
  30. echo $array[$url];
  31.  
  32. header( "Refresh: " . $czas . "; URL=?x=" . $url );
  33.  
  34. ?>



~mike_mech
Go to the top of the page
+Quote Post
strife
post 6.01.2006, 12:36:43
Post #12





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


1. Używaj poprawnego bbCode!

2.
  1. <?php
  2. // rotator banerow
  3.  
  4. $array[1] = '<script language="javascript">var uri = 'http://imppl.tradedoubler.com/imp/img/16173458/1184633?' + new String (Math.random()).substring (2, 11);
  5. document.write('<a href="http://clk.tradedoubler.com/click?p=39590&a=1184633&g=16173458" target="_blank"><img src="'+uri+'" border=0></a>');
  6. </script>';
  7.  
  8. $array[2] = '<script language="javascript">
  9. var uri = 'http://imppl.tradedoubler.com/imp/img/1128784/1184633?' + new String (Math.random()).substring (2, 11);
  10. document.write('<a href="http://clk.tradedoubler.com/click?p=22131&a=1184633&g=1128784" target="_blank"><img src="'+uri+'" border=0></a>');
  11. </script>';
  12.  
  13. $array[3] = 'bannerek 3';
  14. $array[4] = 'bannerek 4';
  15. $array[5] = 'bannerek 5';
  16.  
  17. $czas = 5; // 5 sekund
  18.  
  19. $url = (int)$_GET['x'];
  20.  
  21. if ( empty ( $url ) or $url >= count ( $array ) )
  22. {
  23.    $url = 1;
  24. }
  25. else
  26. {
  27.    $url++;
  28. }
  29. echo $array[$url];
  30.  
  31. header( "Refresh: " . $czas . "; URL=?x=" . $url );
  32.  
  33. ?>

Nie miałeś przez ' wstawionego znaku \ który informuje iż nie będzie on traktowany specjalnie, jeśli jesteś dociekliwy poszukaj...

Pozdrawiam!


--------------------
Go to the top of the page
+Quote Post
-Guest-
post 6.01.2006, 12:48:01
Post #13





Goście







Ok juz prawie, jest jeszce jeden błąd z funkcę header

Kod
Warning: Cannot modify header information - headers already sent by (output started at c:\usr\krasnal\www\eurobarre\ebay.php:6) in c:\usr\krasnal\www\eurobarre\ebay.php on line 83


  1. <?php
  2. // rotator banerow :]
  3.  
  4. $array[1] = '<script language="javascript"> var uri = 'http://imppl.tradedoubler.com/imp/img/16173458/1184633?' + new String (Math.random()).substring (2, 11);
  5. document.write('<a href="http://clk.tradedoubler.com/click?p=39590&a=1184633&g=16173458" target="_blank"><img src="'+uri+'" border=0></a>');
  6. </script>';
  7.  
  8. $array[2] = '<script language="javascript"> var uri = 'http://imppl.tradedoubler.com/imp/img/1128784/1184633?' + new String (Math.random()).substring (2, 11);
  9. document.write('<a href="http://clk.tradedoubler.com/click?p=22131&a=1184633&g=1128784" target="_blank"><img src="'+uri+'" border=0></a>');
  10. </script>';
  11.  
  12. $array[3] = 'bannerek 3';
  13. $array[4] = 'bannerek 4';
  14. $array[5] = 'bannerek 5';
  15.  
  16. $czas = 5; // 5 sekund
  17.  
  18. $url = (int)$_GET['x'];
  19.  
  20. if ( empty ( $url ) or $url >= count ( $array ) )
  21. {
  22. $url = 1;
  23. }
  24. else
  25. {
  26. $url++;
  27. }
  28. echo $array[$url];
  29.  
  30. header( "Refresh: " . $czas . "; URL=?x=" . $url );
  31.  
  32. ?>
Go to the top of the page
+Quote Post
strife
post 6.01.2006, 12:54:46
Post #14





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


http://forum.php.pl/index.php?showtopic=39661

znowu headery laugh.gif


--------------------
Go to the top of the page
+Quote Post
-Guest-
post 6.01.2006, 13:24:26
Post #15





Goście







czyli muszę dać na samym początku te linijkę??


  1. <?php ob_start(); ?>


bo ten "skrypt" jest zagnieżdźony w zwykłym HTML'u (tylko rozszerzenie plików zostało zmienione na plik.php

tak wyczytałem z innych a na końcu muszę dodać

  1. <?php
  2. ?>
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: 24.07.2025 - 19:57