Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP/MySQL] Select powinno zaznaczyć, a nie zaznacza
Koniczynka
post
Post #1





Grupa: Zarejestrowani
Postów: 61
Pomógł: 0
Dołączył: 24.05.2006

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


Witajcie,

Mam problem z funkcją, która powinna zaznaczać select przez explode'owane dane.

  1. <?php
  2. function rezerwowi()
  3. {
  4. $this->wyciaganie();
  5. $this->rezerwowibaza = $this->row['zmiany_mecze'];
  6. $this->rezer = explode("ćó" , $this->rezerwowibaza);
  7.  
  8. $this->rezer1 = $this->rezer[0];
  9. $this->rezer2 = $this->rezer[3];
  10. $this->rezer3 = $this->rezer[4];  
  11. $this->rezer4 = $this->rezer[5];
  12. $this->rezer5 = $this->rezer[2];
  13. $this->rezer6 = $this->rezer[1];
  14.  
  15. $this->rezer7 = $this->rezer[6];
  16. $this->rezer8 = $this->rezer[9];
  17. $this->rezer9 = $this->rezer[10];
  18. $this->rezer10 = $this->rezer[11];
  19. $this->rezer11 = $this->rezer[8];
  20. $this->rezer12 = $this->rezer[7];
  21. $this->rezer13 = $this->rezer[12];
  22. $this->rezer14 = $this->rezer[15];
  23. $this->rezer15 = $this->rezer[16];
  24. $this->rezer16 = $this->rezer[17];
  25. $this->rezer17 = $this->rezer[14];
  26. $this->rezer18 = $this->rezer[13];
  27. $this->rezer19 = $this->rezer[18];
  28. $this->rezer20 = $this->rezer[21];
  29. $this->rezer21 = $this->rezer[22];
  30. $this->rezer22 = $this->rezer[23];
  31. $this->rezer23 = $this->rezer[20];
  32. $this->rezer24 = $this->rezer[19];
  33. echo $this->rezer1;
  34. echo "<select name=nam>";
  35. $this->pytaniea10="SELECT * FROM zawodnicy ORDER BY nazwisko_zawodnicy ASC "; 
  36. $this->result3a10 = mysql_query ($this->pytaniea10) 
  37.  or die ("błąd zapytania "); 
  38. while ($this->row3a10 = mysql_fetch_array ($this->result3a10)){ 
  39. if ($this->row3a10['id_zawodnicy'] == $this->rezer1) $this->zaznacz="selected"; else $this->zaznacz=""; 
  40.  
  41. echo "<option value='".$this->row3a10['id_zawodnicy']."' ".$this->zaznacz.">".$this->row3a10['nazwisko_zawodnicy']." ".$this->row3a10['imie_zawodnicy']."</option>"; 
  42. } 
  43. echo "</select>";
  44. }
  45. ?>


Problem tkwi w $this->rezer1 . Otóż kiedy jest wywoływana jego wartość, pokazuje się ona zgodnie z prawdą. Kiedy pobieram dane z WHERE id_zawodnicy = $this->rezer1, także działa. Jednak w wypadku, w którym ma zaznaczać dodane wcześniej pole, $this->rezer1 przybiera pustą wartość. Dlaczego tak się dzieje, bo moja walka przypomina tą z Don Kichote z wiatrakami.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
webJ@cob
post
Post #2





Grupa: Zarejestrowani
Postów: 66
Pomógł: 1
Dołączył: 28.02.2007
Skąd: Kraków

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


Przykład

<select name="select">
<option value="a">Test A</option>
<option value="b" selected="selected">Test B</option>
</select>

Zatem:
parametr selected="selected" automatycznie zaznacza w tym wypadku ustawia jako pierwszy element.

Ten post edytował webJ@cob 27.06.2007, 12:45:10


--------------------
Sprawdź kiedy marzenia stają się inspiracją.
e-Zarządzania firmą | e-Biznes | Strony.Serwisy.Portale Internetowe
www.webarts.pl
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: 20.08.2025 - 09:56