Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [sql]Dwa razy ten sam rekord
klekot
post
Post #1





Grupa: Zarejestrowani
Postów: 78
Pomógł: 0
Dołączył: 16.08.2005

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


Witam! Mam pytanie. Czemu na stronie http://www.napijmysie.cba.pl/teledyski/tel...p;orderby=dance
wyswietla mi sie dwa razy ten sam rekord? W bazie jest tylko jeden o danych parametrach.
Sorry ze daje taki dlugo kod, ale nie wiem ile wam potrzeba.

  1. <?
  2. $orderby = $_GET['orderby'];
  3.  
  4.  
  5.  
  6. if ($orderby==Techno){
  7.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='techno'")or die(mysql_error());
  8.  while($fetch = mysql_fetch_array($mysql)) {
  9.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  10.  print("<br>".$fetch['czas']);
  11.  print("<br>".$fetch['opis']);
  12.  print("<br>".$fetch['adres']);
  13.  
  14.  }
  15.  
  16.  
  17.  
  18. }
  19.  
  20. if ($orderby==country){
  21.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  22.  while($fetch = mysql_fetch_array($mysql)) {
  23.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  24.  print("<br>".$fetch['czas']);
  25.  print("<br>".$fetch['opis']);
  26.  print("<br>".$fetch['adres']);
  27.  }
  28.  
  29.  
  30.  
  31. }
  32.  
  33. if ($orderby==dance){
  34.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  35.  while($fetch = mysql_fetch_array($mysql)) {
  36.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  37.  print("<br>".$fetch['czas']);
  38.  print("<br>".$fetch['opis']);
  39.  print("<br>".$fetch['adres']);
  40.  }
  41.  
  42.  
  43.  
  44. }
  45.  
  46. if ($orderby==disco_polo){
  47.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  48.  while($fetch = mysql_fetch_array($mysql)) {
  49.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  50.  print("<br>".$fetch['czas']);
  51.  print("<br>".$fetch['opis']);
  52.  print("<br>".$fetch['adres']);
  53.  }
  54.  
  55.  
  56.  
  57. }
  58.  
  59. if ($orderby==dla_dzieci){
  60.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  61.  while($fetch = mysql_fetch_array($mysql)) {
  62.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  63.  print("<br>".$fetch['czas']);
  64.  print("<br>".$fetch['opis']);
  65.  print("<br>".$fetch['adres']);
  66.  }
  67.  
  68.  
  69.  
  70. }
  71.  
  72. if ($orderby==hip-hop){
  73.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  74.  while($fetch = mysql_fetch_array($mysql)) {
  75.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  76.  print("<br>".$fetch['czas']);
  77.  print("<br>".$fetch['opis']);
  78.  print("<br>".$fetch['adres']);
  79.  }
  80.  
  81.  
  82.  
  83. }
  84.  
  85. if ($orderby==jazz){
  86.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  87.  while($fetch = mysql_fetch_array($mysql)) {
  88.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  89.  print("<br>".$fetch['czas']);
  90.  print("<br>".$fetch['opis']);
  91.  print("<br>".$fetch['adres']);
  92.  }
  93.  
  94.  
  95.  
  96. }
  97.  
  98. if ($orderby==metal){
  99.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  100.  while($fetch = mysql_fetch_array($mysql)) {
  101.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  102.  print("<br>".$fetch['czas']);
  103.  print("<br>".$fetch['opis']);
  104.  print("<br>".$fetch['adres']);
  105.  }
  106.  
  107.  
  108.  
  109. }
  110.  
  111. if ($orderby==pop){
  112.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  113.  while($fetch = mysql_fetch_array($mysql)) {
  114.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  115.  print("<br>".$fetch['czas']);
  116.  print("<br>".$fetch['opis']);
  117.  print("<br>".$fetch['adres']);
  118.  }
  119.  
  120.  
  121.  
  122. }
  123.  
  124. if ($orderby==rock){
  125.  $mysql = mysql_query("SELECT * FROM `teledyski` WHERE kategoria='$orderby'")or die(mysql_error());
  126.  while($fetch = mysql_fetch_array($mysql)) {
  127.  print('<br><br><br> '.$fetch['wykonawca'].' - '.$fetch['tytul'] );
  128.  print("<br>".$fetch['czas']);
  129.  print("<br>".$fetch['opis']);
  130.  print("<br>".$fetch['adres']);
  131.  }
  132.  
  133.  }
  134.  
  135.  
  136. ?>


pomoze ktos?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
klekot
post
Post #2





Grupa: Zarejestrowani
Postów: 78
Pomógł: 0
Dołączył: 16.08.2005

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


ok, dziala, dzieki, ale jeszcze jak bys mi mogl wytlumaczyc czemu to moje jest zle, to bylo by fajnie
Go to the top of the page
+Quote Post
Cienki1980
post
Post #3





Grupa: Przyjaciele php.pl
Postów: 1 590
Pomógł: 40
Dołączył: 11.01.2007
Skąd: Centrum

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


Cytat(klekot @ 14.03.2008, 21:40:04 ) *
ok, dziala, dzieki, ale jeszcze jak bys mi mogl wytlumaczyc czemu to moje jest zle, to bylo by fajnie


Hmm nie wiem dlaczego nie działało to co Ty tam miałeś. Ja stawiałbym na to, że w if'ach brakowało Ci ' .. czyli
  1. <?php
  2. if($orderby=='Techno')
  3. .
  4. .
  5. ?>


Do tego typu rzeczy polecałbym składnie switch.. case lub if .. elseif ... else
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: 6.10.2025 - 10:01