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"])){

(IMG:http://forum.php.pl/style_emoticons/default/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
CanoR
post
Post #2





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

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


Dobra zaczne od poczatku teraz dokladniej (IMG:http://forum.php.pl/style_emoticons/default/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 (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) )
Go to the top of the page
+Quote Post
tanwel_programme...
post
Post #3





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 (IMG:http://forum.php.pl/style_emoticons/default/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

Posty w temacie
- CanoR   Problem z funkcja if oraz $_GET   3.04.2009, 14:15:18
- - Spawnm   lepsze empty: [PHP] pobierz, plaintext <?phpif...   3.04.2009, 14:20:33
- - CanoR   Ale czy to zadziala w moim przypadku ?   3.04.2009, 14:22:14
- - piotrooo89   CytatAle czy to zadziala w moim przypadku ? spraw...   3.04.2009, 14:23:42
- - CanoR   Tamta funkcja dziala ale mam problem z : if(isset(...   3.04.2009, 14:32:10
|- - piotrooo89   Cytat(CanoR @ 3.04.2009, 15:32:10 ) t...   3.04.2009, 14:38:25
|- - CanoR   Cytat(piotrooo89 @ 3.04.2009, 15:38:2...   3.04.2009, 14:46:21
- - tanwel_programmer   RE: Problem z funkcja if oraz $_GET   3.04.2009, 14:35:24
- - CanoR   Chce przerobic if(isset($_GET["spells...   3.04.2009, 14:38:21
|- - tanwel_programmer   Cytat(CanoR @ 3.04.2009, 15:38:21 ) C...   3.04.2009, 14:42:21
- - Spawnm   co nie działa ? daj kod w normalny bbcode , łamies...   3.04.2009, 14:48:23
- - piotrooo89   CytatSprawdzilem ten sposob i musze z przykroscia ...   3.04.2009, 14:48:53
- - CanoR   Dobra zaczne od poczatku teraz dokladniej mam sob...   3.04.2009, 14:55:54
|- - tanwel_programmer   Wrzóć wszystko na swicha'a i twój problem znik...   3.04.2009, 15:09:50
- - CanoR   Duzo mi to nie mowi ale ok moze cos wymysle dziek...   3.04.2009, 15:11:35
- - ikssde   Chodziło mu o : [PHP] pobierz, plaintext <?php...   3.04.2009, 15:14:44
- - CanoR   wiem ze mu oto chodzilo ale nie znam tego .... wla...   3.04.2009, 15:57:46
|- - tanwel_programmer   Cytat(CanoR @ 3.04.2009, 16:57:46 ) w...   3.04.2009, 16:09:22
- - CanoR   OK dzieki nadal nie mam wszystkiego do mojej stron...   3.04.2009, 17:45:27


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: 16.10.2025 - 07:00