Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> includuje dwa zamiast jednego if, chce żeby ncludowało tylko jedno
miki_ok
post
Post #1





Grupa: Zarejestrowani
Postów: 88
Pomógł: 0
Dołączył: 17.08.2003
Skąd: Nowy Targ

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


Mam takie coś.
  1. <?php
  2.  
  3. $typ= $HTTP_GET_VARS["typ"];
  4. $imprezy= $HTTP_GET_VARS["imprezy"];
  5. $index= $HTTP_GET_VARS["imprezy"];
  6.  
  7. if($typ==""){include("meta/dzien.txt");}
  8. if($typ=="sportowe"){include("meta/sport.txt");}
  9. if($typ=="wystawy"){include("meta/wystawy.txt");}
  10. if($typ=="teatr"){include("meta/teatr.txt"); }
  11. if($typ=="wszystkie"){include("meta/dzien.txt ");}
  12. if($typ=="rozmaitosci"){ include("meta/rozmaitosci.txt");}
  13. if(file_exists("$imprezy.html")) {include("meta/kalendarz_imprez.txt");}
  14. if($imprezy==""){include_once("meta/wszystkie.txt");}
  15. else
  16. include("meta/puste.txt");
  17.  
  18. ?>

Chodzi o to że jeżeli dodam do tego else on mi wywala po dwa na raz.
Powinien jedno?
Czy jest możliwość napisać coś żeby pokazywało tylko jedno.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Hacker
post
Post #2





Grupa: Zarejestrowani
Postów: 225
Pomógł: 0
Dołączył: 1.11.2005

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


to się nadaje chyba na Przedszkole...
  1. <?php
  2.  
  3. $typ= $HTTP_GET_VARS["typ"];
  4. $imprezy= $HTTP_GET_VARS["imprezy"];
  5. $index= $HTTP_GET_VARS["imprezy"];
  6.  
  7. if($typ==""){include("meta/dzien.txt");}
  8. if($typ=="sportowe"){include("meta/sport.txt");}
  9. if($typ=="wystawy"){include("meta/wystawy.txt");}
  10. if($typ=="teatr"){include("meta/teatr.txt"); }
  11. if($typ=="wszystkie"){include("meta/dzien.txt ");}
  12. if($typ=="rozmaitosci"){ include("meta/rozmaitosci.txt");}
  13. if(file_exists("$imprezy.html")) {include("meta/kalendarz_imprez.txt");}
  14. if($imprezy==""){include_once("meta/wszystkie.txt");}
  15. else
  16. include("meta/puste.txt");
  17.  
  18. ?>

A teraz pytanie za 100 zł do którego if-a odnosi się ten else?
  1. <?php
  2.  
  3.  
  4. $typ= $HTTP_GET_VARS["typ"];
  5. $imprezy= $HTTP_GET_VARS["imprezy"];
  6. $index= $HTTP_GET_VARS["imprezy"];
  7.  
  8. if($typ==""){include("meta/dzien.txt");}
  9. elseif($typ=="sportowe"){include("meta/sport.txt");}
  10. elseif($typ=="wystawy"){include("meta/wystawy.txt");}
  11. elseif($typ=="teatr"){include("meta/teatr.txt"); }
  12. elseif($typ=="wszystkie"){include("meta/dzien.txt ");}
  13. elseif($typ=="rozmaitosci"){ include("meta/rozmaitosci.txt");}
  14. elseif(file_exists("$imprezy.html")) {include("meta/kalendarz_imprez.txt");}
  15. elseif($imprezy==""){include_once("meta/wszystkie.txt");}
  16. else
  17. include("meta/puste.txt");
  18.  
  19.  
  20. ?>


albo
  1. <?php
  2.  
  3. $typ= $HTTP_GET_VARS["typ"];
  4. $imprezy= $HTTP_GET_VARS["imprezy"];
  5. $index= $HTTP_GET_VARS["imprezy"];
  6. if (empty($typ) && empty($imprezy))
  7. include("meta/puste.txt");
  8. else
  9. {
  10. if($typ==""){include("meta/dzien.txt");}
  11. if($typ=="sportowe"){include("meta/sport.txt");}
  12. if($typ=="wystawy"){include("meta/wystawy.txt");}
  13. if($typ=="teatr"){include("meta/teatr.txt"); }
  14. if($typ=="wszystkie"){include("meta/dzien.txt ");}
  15. if($typ=="rozmaitosci"){ include("meta/rozmaitosci.txt");}
  16. if(file_exists("$imprezy.html")) {include("meta/kalendarz_imprez.txt");}
  17. if($imprezy==""){include_once("meta/wszystkie.txt");}
  18. }
  19.  
  20. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 15:22