Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]dodawanie głosów
malaAga
post
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 29.08.2015

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


Witam,
mam problem z dodawaniem głosów do bazy tzn dodaje mi głos ale zawsze do ostatniego pytania. Pomoże ktoś?

  1. if(isset($_POST["submit"]))
  2. {
  3. $id_user= $_SESSION['logged'];
  4. $glos=$_POST["glos"];
  5. $pytt=$_SESSION['licznik'];
  6.  
  7. $add= mysql_query("INSERT INTO odpowiedzi SET id_user='$id_user', glos='$glos', id_pyt='$pytt'") or die('Błąd1');
  8.  
  9. }else
  10. {
  11. $referendum=mysql_query("SELECT * FROM referendum WHERE data_end >= current_date AND data_begin <= current_date " ) or die('Błąd zapytania1');
  12.  
  13. if (mysql_num_rows($referendum) > 0)
  14. {
  15. $ref = mysql_fetch_assoc($referendum) ;
  16. $id_ref =$ref['id_ref'];
  17.  
  18. echo "
  19. <strong>".$ref['tytul']."</strong>
  20. <br ><p>Ważne od: ".$ref['data_begin']. " do: ".$ref['data_end']."</p>";
  21. // echo "$id_ref";
  22.  
  23. }
  24.  
  25. $pytania=mysql_query("SELECT * FROM pytania WHERE id_ref = $id_ref" ) or die('Błąd zapytania2');
  26.  
  27. if (mysql_num_rows($pytania) > 0)
  28. {
  29. while($pyt = mysql_fetch_array($pytania))
  30. {
  31. echo "
  32. <form action='#' method='POST'>
  33. <fieldset>
  34. <legend>" .$pyt['pytanie']." id " .$pyt['id_pyt']."</legend>";
  35. $_SESSION['licznik'] = $pyt['id_pyt'];
  36.  
  37. ?>
  38. <input type='radio' name='glos' <?php if (isset($glos) && $glos=='tak') echo 'tak' ?> value='tak'>tak
  39. <input type='radio' name='glos' <?php if (isset($glos) && $glos=='nie') echo 'checked'?> value='nie'>nie
  40. <br><input type='submit' name='submit' class='buton' value='Głosuj'/>
  41. </fieldset>
  42. </form>
  43. <?php }
  44. }
  45. }

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Wszytkim RADIO nadajesz to samo NAME wiec nie oczekuj, ze formularz wysle ci to rozroznione.
Kazda grupa RADIO ma miec swoje wlasne NAME
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: 7.10.2025 - 09:03