Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z funkcja if oraz $_GET
CanoR
post
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


Witam mam problem z funkcja IF oraz z metoda $_GET...
chce osiagnac efekt zaawansowanej strony PHP lecz zatrzymalem sie w pewnym miejscu
oto kod : Kod:
<?php

if(!isset($_GET["spells"])){
echo "<span class='orange'><a href='?spells=1.1'>Arcane</a><br />
<a href='?spells=1.2'>Fire</a><br />
<a href='?spells=1.3'>Frost</a></span><br />";
$wynik1=mysql_query("select * from news ORDER BY `news_data` DESC");
while($rekord=mysql_fetch_array($wynik1)){
$nadawca=mysql_fetch_array(mysql_query("select user_login from users where user_id=".$rekord["news_autor"]));
echo "<div id='news'>
<div class='head'><a href='?news=".$rekord["news_id"]."'><span class='title'>".$rekord["news_temat"]."</span></a><br />
<span class='text'>".$nadawca["user_login"].", ".$rekord["news_data"]."</span></div><br />
".$rekord["news_tresc"]."<br />
</div>";
}
}
else if($_GET["spells"] == 1.1){
$id=intval($_GET["spells"] == 1.1);
$wynik=mysql_query("select * from spells_mag_arcane ORDER BY `level` ASC");
}
else if($_GET["spells"] == 1.2){
$id=intval($_GET["spells"] == 1.2);
$wynik=mysql_query("select * from spells_mag_fire ORDER BY `level` ASC");
}
else if($_GET["spells"] == 1.3){
$id=intval($_GET["spells"] == 1.3);
$wynik=mysql_query("select * from spells_mag_frost ORDER BY `level` ASC");
}
if(isset($_GET["spells"])){
echo "<table>
<tr>
<td width=3%>Ikona</td>
<td width=50%>Nazwa</td>
<td width=5%>Level</td>
<td width=5%>Szkoła</td>
<td width=5%>Reagenty</td>
<td width=5%>Otrzymywanie</td>
<td width=5%>Skill</td>
</tr>";
if(!mysql_num_rows($wynik))echo "<tr><td colspan=4 style='text-align:center'>Nie znaleziono żadnych zaklęć w tym dziale!</td></tr>";
while($rekord=mysql_fetch_array($wynik)){
echo "<tr>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'><img src='".$rekord["ikona"]."'></span></a></td>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'>".$rekord["nazwa"]."</span></a></td>
<td>".$rekord["level"]."</td>
<td>".$rekord["szkola"]."</td>
<td>".$rekord["reagenty"]."</td>
<td>".$rekord["otrzymywanie"]."</td>
<td>".$rekord["skill"]."</td></tr>";
}
echo "</table>";
}

?>




chodzi mi oto jak mamy Kod:
if(!isset($_GET["spells"])){

czy niedaloby sie zrobic czegos aby w jednej instrukcji, warunku dodac jeszcze inne $_GET czyli cos takiego : Kod:
if(!isset($_GET["spells"]) or ($_GET["news"])){

questionmark.gif potrzebne mi to bo chce cala strone oprzec o jedna index.php w ktorej beda wszystkie podstrony...

prosze o pomoc i z gory wielkie dzieki

CanoR
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 18)
Spawnm
post
Post #2





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




lepsze empty:
  1. <?php
  2. if(empty($_GET['one']) or empty($_GET['two']) ){
  3. //są puste
  4. }
  5. ?>
Go to the top of the page
+Quote Post
CanoR
post
Post #3





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


Ale czy to zadziala w moim przypadku ?
Go to the top of the page
+Quote Post
piotrooo89
post
Post #4


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




Cytat
Ale czy to zadziala w moim przypadku ?


sprawdź i nam powiedz...


--------------------
Go to the top of the page
+Quote Post
CanoR
post
Post #5





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


Tamta funkcja dziala ale mam problem z :
if(isset($_GET["spells"])){
echo "<table>
<tr>
<td width=3%>Ikona</td>
<td width=50%>Nazwa</td>
<td width=5%>Level</td>
<td width=5%>Szkoła</td>
<td width=5%>Reagenty</td>
<td width=5%>Otrzymywanie</td>
<td width=5%>Skill</td>
</tr>";
if(!mysql_num_rows($wynik))echo "<tr><td colspan=4 style='text-align:center'>Nie znaleziono żadnych zaklęć w tym dziale!</td></tr>";
while($rekord=mysql_fetch_array($wynik)){
echo "<tr>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'><img src='".$rekord["ikona"]."'></span></a></td>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'>".$rekord["nazwa"]."</span></a></td>
<td>".$rekord["level"]."</td>
<td>".$rekord["szkola"]."</td>
<td>".$rekord["reagenty"]."</td>
<td>".$rekord["otrzymywanie"]."</td>
<td>".$rekord["skill"]."</td></tr>";
}
echo "</table>";
}

?>



trzeba to jakos przerobic
Go to the top of the page
+Quote Post
tanwel_programme...
post
Post #6





Grupa: Zarejestrowani
Postów: 36
Pomógł: 6
Dołączył: 21.03.2009
Skąd: Obecny :)

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


Cytat(CanoR @ 3.04.2009, 15:15:18 ) *
Witam mam problem z funkcja IF oraz z metoda $_GET...
chce osiagnac efekt zaawansowanej strony PHP lecz zatrzymalem sie w pewnym miejscu
oto kod : Kod:
<?php

if(!isset($_GET["spells"])){
echo "<span class='orange'><a href='?spells=1.1'>Arcane</a><br />
<a href='?spells=1.2'>Fire</a><br />
<a href='?spells=1.3'>Frost</a></span><br />";
$wynik1=mysql_query("select * from news ORDER BY `news_data` DESC");
while($rekord=mysql_fetch_array($wynik1)){
$nadawca=mysql_fetch_array(mysql_query("select user_login from users where user_id=".$rekord["news_autor"]));
echo "<div id='news'>
<div class='head'><a href='?news=".$rekord["news_id"]."'><span class='title'>".$rekord["news_temat"]."</span></a><br />
<span class='text'>".$nadawca["user_login"].", ".$rekord["news_data"]."</span></div><br />
".$rekord["news_tresc"]."<br />
</div>";
}
}
else if($_GET["spells"] == 1.1){
$id=intval($_GET["spells"] == 1.1);
$wynik=mysql_query("select * from spells_mag_arcane ORDER BY `level` ASC");
}
else if($_GET["spells"] == 1.2){
$id=intval($_GET["spells"] == 1.2);
$wynik=mysql_query("select * from spells_mag_fire ORDER BY `level` ASC");
}
else if($_GET["spells"] == 1.3){
$id=intval($_GET["spells"] == 1.3);
$wynik=mysql_query("select * from spells_mag_frost ORDER BY `level` ASC");
}
if(isset($_GET["spells"])){
echo "<table>
<tr>
<td width=3%>Ikona</td>
<td width=50%>Nazwa</td>
<td width=5%>Level</td>
<td width=5%>Szkoła</td>
<td width=5%>Reagenty</td>
<td width=5%>Otrzymywanie</td>
<td width=5%>Skill</td>
</tr>";
if(!mysql_num_rows($wynik))echo "<tr><td colspan=4 style='text-align:center'>Nie znaleziono żadnych zaklęć w tym dziale!</td></tr>";
while($rekord=mysql_fetch_array($wynik)){
echo "<tr>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'><img src='".$rekord["ikona"]."'></span></a></td>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'>".$rekord["nazwa"]."</span></a></td>
<td>".$rekord["level"]."</td>
<td>".$rekord["szkola"]."</td>
<td>".$rekord["reagenty"]."</td>
<td>".$rekord["otrzymywanie"]."</td>
<td>".$rekord["skill"]."</td></tr>";
}
echo "</table>";
}

?>




chodzi mi oto jak mamy Kod:
if(!isset($_GET["spells"])){

czy niedaloby sie zrobic czegos aby w jednej instrukcji, warunku dodac jeszcze inne $_GET czyli cos takiego : Kod:
if(!isset($_GET["spells"]) or ($_GET["news"])){

questionmark.gif potrzebne mi to bo chce cala strone oprzec o jedna index.php w ktorej beda wszystkie podstrony...

prosze o pomoc i z gory wielkie dzieki

CanoR

A ja bym zaproponował coś takiego:
Kod
if(empty($_GET["spells"]) | !empty($_GET["news"])){....}


Cytat(CanoR @ 3.04.2009, 15:32:10 ) *
Tamta funkcja dziala ale mam problem z :
if(isset($_GET["spells"])){
echo "<table>
<tr>
<td width=3%>Ikona</td>
<td width=50%>Nazwa</td>
<td width=5%>Level</td>
<td width=5%>Szkoła</td>
<td width=5%>Reagenty</td>
<td width=5%>Otrzymywanie</td>
<td width=5%>Skill</td>
</tr>";
if(!mysql_num_rows($wynik))echo "<tr><td colspan=4 style='text-align:center'>Nie znaleziono żadnych zaklęć w tym dziale!</td></tr>";
while($rekord=mysql_fetch_array($wynik)){
echo "<tr>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'><img src='".$rekord["ikona"]."'></span></a></td>
<td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'>".$rekord["nazwa"]."</span></a></td>
<td>".$rekord["level"]."</td>
<td>".$rekord["szkola"]."</td>
<td>".$rekord["reagenty"]."</td>
<td>".$rekord["otrzymywanie"]."</td>
<td>".$rekord["skill"]."</td></tr>";
}
echo "</table>";
}

?>



trzeba to jakos przerobic

A co chcesz tu przerabiać ?
Go to the top of the page
+Quote Post
CanoR
post
Post #7





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


Chce przerobic

if(isset($_GET["spells"])){



poniewaz empty sie z ta funkcja wyklucza
Go to the top of the page
+Quote Post
piotrooo89
post
Post #8


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




Cytat(CanoR @ 3.04.2009, 15:32:10 ) *
trzeba to jakos przerobic


jaja sobie z nas robisz? nic nie piszesz co chcesz kod wklejasz w postaci takiej papki że aż oczy bolą. jakieś elementarne zasady by się przydały. (kod dawaj w [.php]


//EDIT

  1. <?php
  2. if(!empty($_GET["spells"]))
  3. ?>


Ten post edytował piotrooo89 3.04.2009, 14:40:16


--------------------
Go to the top of the page
+Quote Post
tanwel_programme...
post
Post #9





Grupa: Zarejestrowani
Postów: 36
Pomógł: 6
Dołączył: 21.03.2009
Skąd: Obecny :)

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


Cytat(CanoR @ 3.04.2009, 15:38:21 ) *
Chce przerobic

if(isset($_GET["spells"])){



poniewaz empty sie z ta funkcja wyklucza


funkcja isset($VAR) służy do sprawdzania istnienia zmiennej, dla zmiennych tablicy asocjacyjnej wszystkie takie zmienne w php istnieją, jeżeli nie ma zmiennej "xxx" to wartość $_GET["xxx"] tak naprawde istnieje tylko jest pusta, funkcja isset dla tablic $_... zawsze będzie zwracała ci prawdę, trzeba użyć empty($VAR) jeżeli chcesz sprawdzić istnienie danej wartośći.
Go to the top of the page
+Quote Post
CanoR
post
Post #10





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


Cytat(piotrooo89 @ 3.04.2009, 15:38:25 ) *
jaja sobie z nas robisz? nic nie piszesz co chcesz kod wklejasz w postaci takiej papki że aż oczy bolą. jakieś elementarne zasady by się przydały. (kod dawaj w [.php]


//EDIT

  1. <?php
  2. if(!empty($_GET["spells"]))
  3. ?>


Sprawdzilem ten sposob i musze z przykroscia stwierdzic ze nie dziala... sad.gif
Go to the top of the page
+Quote Post
Spawnm
post
Post #11





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




co nie działa ?
daj kod w normalny bbcode , łamiesz regulamin sciana.gif
Go to the top of the page
+Quote Post
piotrooo89
post
Post #12


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




Cytat
Sprawdzilem ten sposob i musze z przykroscia stwierdzic ze nie dziala... sad.gif


to może zbierzesz całe swoje siły witalne, cała moc zen i powiesz nam co chcesz osiągnąć bo pisząc że chcesz przerobić niewiele możemy zajarzyć i strzelamy.


--------------------
Go to the top of the page
+Quote Post
CanoR
post
Post #13





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


Dobra zaczne od poczatku teraz dokladniej biggrin.gif
mam sobie kod:
  1. <?php
  2.  
  3. if(!isset($_GET["spells"])){
  4. echo "<span class='orange'><a href='?spells=1.1'>Arcane</a><br />
  5. <a href='?spells=1.2'>Fire</a><br />
  6. <a href='?spells=1.3'>Frost</a></span><br />";
  7. $wynik1=mysql_query("select * from news ORDER BY `news_data` DESC");
  8. while($rekord=mysql_fetch_array($wynik1)){
  9. $nadawca=mysql_fetch_array(mysql_query("select user_login from users where user_id=".$rekord["news_autor"]));
  10. echo "<div id='news'>
  11. <div class='head'><a href='?news=".$rekord["news_id"]."'><span class='title'>".$rekord["news_temat"]."</span></a><br />
  12. <span class='text'>".$nadawca["user_login"].", ".$rekord["news_data"]."</span></div><br />
  13. ".$rekord["news_tresc"]."<br />
  14. </div>";
  15. }
  16. }
  17. else if($_GET["spells"] == 1.1){
  18. $id=intval($_GET["spells"] == 1.1);
  19. $wynik=mysql_query("select * from spells_mag_arcane ORDER BY `level` ASC");
  20. }
  21. else if($_GET["spells"] == 1.2){
  22. $id=intval($_GET["spells"] == 1.2);
  23. $wynik=mysql_query("select * from spells_mag_fire ORDER BY `level` ASC");
  24. }
  25. else if($_GET["spells"] == 1.3){
  26. $id=intval($_GET["spells"] == 1.3);
  27. $wynik=mysql_query("select * from spells_mag_frost ORDER BY `level` ASC");
  28. }
  29. if(isset($_GET["spells"])){
  30. echo "<table>
  31. <tr>
  32. <td width=3%>Ikona</td>
  33. <td width=50%>Nazwa</td>
  34. <td width=5%>Level</td>
  35. <td width=5%>Szkoła</td>
  36. <td width=5%>Reagenty</td>
  37. <td width=5%>Otrzymywanie</td>
  38. <td width=5%>Skill</td>
  39. </tr>";
  40. if(!mysql_num_rows($wynik))echo "<tr><td colspan=4 style='text-align:center'>Nie znaleziono żadnych zaklęć w tym dziale!</td></tr>";
  41. while($rekord=mysql_fetch_array($wynik)){
  42. echo "<tr>
  43. <td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'><img src='".$rekord["ikona"]."'></span></a></td>
  44. <td><a href='?spell=".$rekord["id"]."' onmouseover=".$rekord["span"]."ShowTT ('".$rekord["id"]."')".$rekord["span"]." onmouseout=".$rekord["span"]."HideTT()".$rekord["span"]."><span class='".$rekord["color"]."'>".$rekord["nazwa"]."</span></a></td>
  45. <td>".$rekord["level"]."</td>
  46. <td>".$rekord["szkola"]."</td>
  47. <td>".$rekord["reagenty"]."</td>
  48. <td>".$rekord["otrzymywanie"]."</td>
  49. <td>".$rekord["skill"]."</td></tr>";
  50. }
  51. echo "</table>";
  52. }
  53.  
  54. ?>


Chcialbym aby normalnie na stronie zostal wyswietlony
  1. <?php
  2. echo "<span class='orange'><a href='?spells=1.1'>Arcane</a><br />
  3. <a href='?spells=1.2'>Fire</a><br />
  4. <a href='?spells=1.3'>Frost</a></span><br />";
  5. $wynik1=mysql_query("select * from news ORDER BY `news_data` DESC");
  6. while($rekord=mysql_fetch_array($wynik1)){
  7. $nadawca=mysql_fetch_array(mysql_query("select user_login from users where user_id=".$rekord["news_autor"]));
  8. echo "<div id='news'>
  9. <div class='head'><a href='?news=".$rekord["news_id"]."'><span class='title'>".$rekord["news_temat"]."</span></a><br />
  10. <span class='text'>".$nadawca["user_login"].", ".$rekord["news_data"]."</span></div><br />
  11. ".$rekord["news_tresc"]."<br />
  12. </div>";
  13. ?>

Taki fragment z tabeli news....

A jezeli wykryta zostanie funkcja $_GET["spells"], $_GET["news"] i inne
To ta glowna strona znika a zamiast jej powstaje cos z warunkow IF (np. te spelle albo newsy z komentarzami biggrin.gif)
Go to the top of the page
+Quote Post
tanwel_programme...
post
Post #14





Grupa: Zarejestrowani
Postów: 36
Pomógł: 6
Dołączył: 21.03.2009
Skąd: Obecny :)

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


Wrzóć wszystko na swicha'a i twój problem zniknie smile.gif, jeżeli ten post się powrtórzy kilka razy to przepraszam ale coś nie mogę wysłać.
Go to the top of the page
+Quote Post
CanoR
post
Post #15





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


Duzo mi to nie mowi ale ok biggrin.gif moze cos wymysle dzieki za dobre checi

Ten post edytował CanoR 3.04.2009, 15:12:01
Go to the top of the page
+Quote Post
ikssde
post
Post #16





Grupa: Zarejestrowani
Postów: 217
Pomógł: 40
Dołączył: 20.08.2008

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


Chodziło mu o :

  1. <?php
  2. switch($_GET["spells"])
  3. {
  4.        case "1.1":
  5.        ... zrob costam...
  6.        
  7.        case "1.2":
  8.        ... zrob costam...
  9. }
  10. ?>
Go to the top of the page
+Quote Post
CanoR
post
Post #17





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


wiem ze mu oto chodzilo ale nie znam tego ....
wlasnie poznaje nowy PHP tongue.gif
jak sie uda to normalnie was pokocham smile.gif

//EDIT
Poradzilem sobie Dziekuje wszystkim dlatego dalem wam wszystkim punkty smile.gif Oby zawsze tak mi pomagano to daleko zajde tongue.gif

Ten post edytował CanoR 3.04.2009, 15:58:31
Go to the top of the page
+Quote Post
tanwel_programme...
post
Post #18





Grupa: Zarejestrowani
Postów: 36
Pomógł: 6
Dołączył: 21.03.2009
Skąd: Obecny :)

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


Cytat(CanoR @ 3.04.2009, 16:57:46 ) *
wiem ze mu oto chodzilo ale nie znam tego ....
wlasnie poznaje nowy PHP tongue.gif
jak sie uda to normalnie was pokocham smile.gif

//EDIT
Poradzilem sobie Dziekuje wszystkim dlatego dalem wam wszystkim punkty smile.gif Oby zawsze tak mi pomagano to daleko zajde tongue.gif

No cuż, nie było mnie długi czas botrwają przygotowania do ożenku smile.gif ale po waszych postach proponuję naszemu koledze przeczytać porządnie dokumentację php: <a href="www.php.net/documentation"> Można ją znaleźć tu</a>. Powodzenia w nauce smile.gif
Go to the top of the page
+Quote Post
CanoR
post
Post #19





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 3.04.2009

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


OK dzieki nadal nie mam wszystkiego do mojej strony ale znajde biggrin.gif

Pozdrawiam
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 - 05:25