Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Include to lub to...
domator
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 25.10.2005

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


Witam

Mam sobie jakąś linijkę kodu np:

  1. <?php
  2. if (.......................) include('includes/1.html');
  3. ?>


Teraz chcę zrobić tak aby - if ...... było na zmiane (losowo) raz include('includes/1.html'); a raz aby inkludowało /2.html

Nie znam się na php, ale myśle, że dla Was to pikuś

Dziękuję i pozdrawiam

Laik
Go to the top of the page
+Quote Post
Eagle
post
Post #2





Grupa: Zarejestrowani
Postów: 170
Pomógł: 14
Dołączył: 16.03.2007

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


Nie wiem czy dokładnie Ci o to chodzi ...

  1. <?php
  2. $id;
  3.  
  4. if (.........................)
  5. {
  6. include ("index$id.html")
  7. }
  8. ?>
Go to the top of the page
+Quote Post
domator
post
Post #3





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 25.10.2005

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


Chodziło mi o to aby raz wczytywało 1.html a po odświeżeniu 2.html i tak w kółko. :roll2:
Go to the top of the page
+Quote Post
gWd
post
Post #4





Grupa: Zarejestrowani
Postów: 55
Pomógł: 0
Dołączył: 17.09.2006

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


musisz użyć sesji


--------------------
art of programming
Go to the top of the page
+Quote Post
rojmarek
post
Post #5





Grupa: Zarejestrowani
Postów: 85
Pomógł: 0
Dołączył: 10.09.2005

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


Cytat(gWd @ 19.04.2007, 20:26:38 ) *
musisz użyć sesji

moze uzyc tez randoma... bedzie prawie za kazdym razem inna strona...
Go to the top of the page
+Quote Post
Zeman
post
Post #6





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 29.03.2007

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


Tak jak już wspomniał gWd należy użyć sesji.

  1. <?php
  2. if (isset($_SESSION['licznik']))
  3. $_SESSION['licznik']++;
  4. else 
  5. $_SESSION['licznik'] = 0;
  6. include(($_SESSION['licznik']%2+1).'.html');
  7. ?>


Tak przy okazji, jeśli includuje się warunkowo, to dokumentacja nakazuje umieszczać include wewnątrz nawiasów klamrowych :

  1. <?php
  2. // Ten kod jest NIEPOPRAWNY i nie zadziała zgodnie z oczekiwaniami.
  3. if ($warunek)
  4. include $plik;
  5. else
  6. include $inny;
  7.  
  8.  
  9. // Natomiast ten kod jest POPRAWNY.
  10. if ($warunek) {
  11. include $plik;
  12. } else {
  13. include $inny;
  14. }
  15. ?>


Ten post edytował Zeman 20.04.2007, 00:07:32


--------------------
www.web2biz.pl | trochę o web-usability
Go to the top of the page
+Quote Post
domator
post
Post #7





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 25.10.2005

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


Ok, więc może na konkretnym przykładzie, który mnie interesuje:

  1. <?php 
  2. //komunikat
  3. if (!isset($_COOKIE['komu']) || $_COOKIE['komu']!='informacja') include('news/12-12-07.html');
  4. ?>


...no i naprzemiennie żeby się wyświetlał: 12-12-07.html z 13-12-07.html

Pozdrawiam
Go to the top of the page
+Quote Post
wert1
post
Post #8





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


chodzi ci o skrypt który wyświetla inną stronę komus kto juz widział naszą strone a inną jeśli pierwszy raz ją odwiedza?questionmark.gif

Ten post edytował wert1 20.04.2007, 14:16:54


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
domator
post
Post #9





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 25.10.2005

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


hmm... po prostu nie wiem jak zmodyfikować powyższy kod, aby includował naprzemiennie pliki html.

Pomoże ktośquestionmark.gif sad.gif
Go to the top of the page
+Quote Post
wert1
post
Post #10





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


  1. <?php
  2.  
  3. if(isSet($_COOKIE["znany"])){
  4. include('index1.html');
  5. }
  6. else{
  7. setCookie("znany", "tak", time() + 3600 * 24 * 30);
  8. include('index2.html');
  9. }
  10. ?>


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
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 Aktualny czas: 22.08.2025 - 07:03