1. <?php
  2. $query_anketa = $modx->db->query("
  3. SELECT id, pagetitle, content
  4. FROM site_content
  5. WHERE parent=56
  6. AND published=1 AND deleted=0
  7. ");
  8. $anketa = $modx->db->makeArray($query_anketa);
  9. $st_anket = count($anketa);
  10. if ($st_anket) {
  11. $anketa_id = $anketa[0]['id'];
  12. $query_odgovori = $modx->db->query("
  13. SELECT tv.value
  14. FROM site_content c
  15. LEFT JOIN site_tmplvar_contentvalues tv
  16. ON c.id=tv.contentid
  17. WHERE c.id=$anketa_id AND tv.tmplvarid!=18
  18. LIMIT 10
  19. ");
  20. $odgovori= $modx->db->makeArray($query_odgovori);
  21.  
  22. echo '
  23. <form action="" method="post" id="pool">
  24. <p>'.$anketa[0]['content'].'</p>
  25. <table>
  26. ';
  27. $i=0; foreach($odgovori as $s){ $i++;
  28. echo '
  29. <tr>
  30. <td><input type="radio" name="question" value="'.$i.'"/></td>
  31. <td class="odg">'.$s['value'].'</td>
  32. </tr>
  33. ';
  34. }
  35.  
  36. for($x=1; $x<=count($odgovori); $x++) {
  37. if($_POST['question']==$x) {
  38. $result[$_POST['question']] = 1 ;
  39. }
  40. else {
  41. $result[$x] = 0 ;
  42. }
  43. }
  44.  
  45. echo '</table>
  46. <p>
  47. <br />
  48. <input type="submit" value="Glasuj" class="submit" />
  49. </p>
  50. </form>';
  51. }
  52.  
  53. $query_rezultati = $modx->db->query("
  54. SELECT tv.value
  55. FROM site_content c
  56. LEFT JOIN site_tmplvar_contentvalues tv
  57. ON c.id=tv.contentid
  58. WHERE c.id=$anketa_id AND tv.tmplvarid=18
  59. LIMIT 1
  60. ");
  61. $rezultati= $modx->db->makeArray($query_rezultati);
  62.  
  63. $res= serialize($result);
  64. $query_rezultat = $modx->db->query("
  65. UPDATE site_tmplvar_contentvalues SET value='$res' WHERE tmplvarid =18 AND contentid =57;
  66. ");
  67.  
  68. echo'<pre style="position:absolute;font-size:9px;background:#FFF;">';
  69. print_r (unserialize($res));
  70. print $res;
  71. print (serialize($rezultati));
  72. echo'</pre>';
  73. ?>