Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Klopot z funkcja "if"
podol
post 5.07.2006, 11:19:24
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 12.07.2005
Skąd: Starogard Gdański

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


Mam taki kawalek kodu:

  1. <?php
  2. if ( $row['user_allow_viewonline'] )
  3. {
  4. $user_online_link = '
  5.  
  6. <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . 
  7. POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '
  8. </a>';
  9. $logged_visible_online++;
  10. }
  11. ?>


Jak wstawic kolejna funkce if w ktorej zmienna "$user_online_link" sprawdza czy znajduje się w katalogu "nick" obraz *.jpg o nazwie '.$row['username'].' Jesli instnieje, to wstawia ją jako obraz hiperłącza:

  1. <?php
  2. <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . 
  3. POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>
  4.  
  5. <img src="nick/' . $row['username'] . '">
  6.  
  7. </a>
  8. ?>


Jesli nie ma, to wstawia zwykla nazwe.

  1. <?php
  2. <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . 
  3. POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>
  4.  
  5. ' . $row['username'] . '
  6.  
  7. </a>
  8. ?>



Czy ktos jest w stanie pomóc mi z tym?? smile.gif

Ten post edytował podol 5.07.2006, 12:09:59
Go to the top of the page
+Quote Post
Cysiaczek
post 5.07.2006, 11:53:19
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Jaki masz problem z tym skryptem? Jakiś bład ?


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
podol
post 5.07.2006, 12:10:41
Post #3





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 12.07.2005
Skąd: Starogard Gdański

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


Przeciez pisze - poprawilem jeszcze zeby bylo wyrazniej widac: Jak wstawic kolejna funkcje if...
Go to the top of the page
+Quote Post
Cysiaczek
post 5.07.2006, 12:19:17
Post #4





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




  1. <?php
  2. if (file_exists('nick/'.$row[username].'.jpg')){
  3. print '<img src="nick/'.$row[username].'.jpg">';;
  4. }
  5. ?>


o to chodzi?

Ten post edytował Cysiaczek 5.07.2006, 12:20:27


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
podol
post 5.07.2006, 14:52:32
Post #5





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 12.07.2005
Skąd: Starogard Gdański

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


Tak chodzilo wlasnie o to, tylko nie wiem jak to wkomponowac w:

  1. <?php
  2. if ( $row['user_allow_viewonline'] ) { $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>'; $logged_visible_online++; }
  3. ?>


Mozesz mi pomóc z tym?? smile.gif
Go to the top of the page
+Quote Post
Cysiaczek
post 5.07.2006, 15:07:25
Post #6





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




  1. <?php
  2. if ( $row['user_allow_viewonline'] ) {
  3. $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'];
  4.  
  5. if (file_exists('nick/'.$row[username].'.jpg')){
  6. $user_online_link.='<img src="nick/'.$row[username].'.jpg">'; //jak istnieje, to dkolejsz do linka
  7. }
  8. $user_online_link.='</a>'; //i domknięcie linka
  9.  
  10.  
  11.  $logged_visible_online++;  
  12.  }
  13. ?>


Ten post edytował Cysiaczek 5.07.2006, 15:08:00


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
podol
post 5.07.2006, 15:32:44
Post #7





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 12.07.2005
Skąd: Starogard Gdański

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


niestety nie dziala... sad.gif
Go to the top of the page
+Quote Post
Cysiaczek
post 5.07.2006, 15:35:21
Post #8





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




mogłem gdzieś zrobić błąd składni lub coś podobnego, Pokombinuj troszke. BTW - ustaw sobie obsługe błędów php na E_ALL


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
NetJaro
post 6.07.2006, 08:44:34
Post #9





Grupa: Zarejestrowani
Postów: 475
Pomógł: 0
Dołączył: 1.04.2005
Skąd: Warszawa

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


Nie działa..
Może więcej informacji podasz? Jaki błąd wyskakuje?
Go to the top of the page
+Quote Post
Neotion
post 6.07.2006, 09:36:26
Post #10





Grupa: Zarejestrowani
Postów: 67
Pomógł: 0
Dołączył: 13.09.2004

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


Chyba prościej użyć opertora warunkowego...

  1. <?php
  2. if ( $row['user_allow_viewonline'] ) {
  3. $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . 
  4. $row['user_id']) . '"' . $style_color .'>' 
  5. . $row['username'].file_exists('nick/'.$row[username].'.jpg') ? '<img src="nick/'.$row[username].'.jpg">': ''
  6. .'</a>';
  7.  
  8. $logged_visible_online++;  
  9. }
  10. ?>


--------------------
current: nexcite cms (0.2.5) running on top of netsource framework (0.5.3)

workbench: nsapi | php 5.1.2 | mysql 5.0.18 | phpmyadmin 2.9 rc1 | zend studio 5.2.0 | apache/2.2.0 (linux/suse)
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 - 16:17