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