Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Domyślne zaznaczanie pola wyboru pobranego z bazy
szczabik
post
Post #1





Grupa: Zarejestrowani
Postów: 226
Pomógł: 1
Dołączył: 13.05.2008

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


Mam taki kod który pobiera dane z bazy i umieszcza je w formularzu i wszystko ładnie ale nie wiem jak zrobić by domyślnie była zaznaczona opcja wyboru ta co jest w bazie


Zrobiłem tak i nie do końca działa
  1. <?php
  2. <input type='radio' name='typ' 
  3. value='inna wiadomość' value='1'".($r['typ'] == "3" ? " checked" : "").">
  4. ?>




A cały kod wygląda tak

  1. <?php
  2. if(isset($_GET['edit'])){
  3.  
  4. $id=$_GET['edit'];
  5.  
  6. $wynik = dbquery("SELECT * FROM ".$db_prefix."intencja WHERE modlitwa_id='$id'");
  7.  
  8. $r = dbarray($wynik);
  9.  
  10. $tekst = stripslashes(nl2br($r['tekst']));
  11. $email = $r['email'];
  12. $typ = $r['typ'];
  13.  
  14. echo 
  15. <table align='center' cellpadding='0' cellspacing='1' class='tbl-border' width='100%'><form action='modlitwa.php' method=post> 
  16.  
  17. <tr> 
  18. <td align='right' width='1%' class='tbl2' style='white-space:nowrap'>Treść wpisu:</td> 
  19. <td class='tbl1'><textarea name='tekst' cols='80' rows='8' class='textbox'>$tekst</textarea></td> 
  20. </tr>
  21.  
  22.  
  23. <tr> 
  24. <td align='right' width='1%' class='tbl2' style='white-space:nowrap'>Twój adres email:</td> 
  25. <td class='tbl1'><input type='text' name='email' value='$email' style='width: 150px' class='textbox' maxlength='32'></td> 
  26. </tr>
  27.  
  28. <tr><td align='right' class='tbl2' valign='top'></td>n<td class='tbl1'>
  29. <input type='radio' name='typ' value='prośba o modlitwę' 
  30. value='1'".($r['typ'] == "1" ? " checked" : "").">prośba o modlitwę<input type='radio' name='typ' 
  31. value='podziękowanie' value='2'".($r['typ'] == "1" ? " checked" : "")."> podziękowanie<input type='radio' name='typ' 
  32. value='inna wiadomość' value='1'".($r['typ'] == "3" ? " checked" : "")."> inna wiadomość
  33. </td></tr>
  34.  
  35. <tr>
  36. <td align='right' class='tbl2' valign='top'></td>n<td class='tbl1'>
  37. <input type='submit' name='submit' value='Wyślij' class='textbox'>
  38. <input type='reset' value='Wyszyść' class='textbox'>
  39. </td>
  40. </tr>"; 
  41.  
  42. echo "</table></form>";
  43. ?>


Go to the top of the page
+Quote Post

Posty w temacie


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: 19.08.2025 - 18:38