'; } else{ mysql_query('UPDATE poll_votes SET polloptionid='.$polloptionid.', comment = \''.encodeNoHTMLNoBB($kommentar).'\' WHERE pollid='.$pollid.' and userid = '.$userid); } } // Liefert den Datensatz der Stimme (Nr und eigener Kommentar) function getStimme($pollid, $userid){ $qry = mysql_query('SELECT * FROM poll_votes WHERE pollid = '.$pollid.' and userid = '.$userid); $result = mysql_fetch_assoc($qry); return $result; } function getUmfrage($pollid){ $umfrage = array(); $qry = mysql_query('SELECT p.thema, p.pollid, p.text, u.nickname FROM poll as p inner join user as u on p.ersteller = u.id WHERE pollid='.$pollid); $umfrage['poll'] = mysql_fetch_assoc($qry); $qry = mysql_query('SELECT * FROM poll_options WHERE pollid ='.$pollid); while($result = mysql_fetch_assoc($qry)){ $umfrage['options'][$result['polloptionid']] = $result; } return $umfrage; } function getUmfragen($entries, $page){ $returnArray = array(); $qry = mysql_query('SELECT p.thema, p.pollid, u.nickname FROM poll as p inner join user as u on p.ersteller = u.id LIMIT '.$entries*$page.','.$entries); $i=0; while($result=mysql_fetch_assoc($qry)){ $returnArray[$i++] = $result; } return $returnArray; } function getUmfragenCount(){ $temp = mysql_fetch_assoc(mysql_query('SELECT count(*) as anzahl FROM poll')); return $temp[anzahl]; } function getComments($pollid, $entries, $page){ $returnArray = array(); $sql = 'SELECT polloptionid, comment FROM poll_votes where comment != \'\' and pollid= '.$pollid.' LIMIT '.$entries*$page.','.$entries; $qry = mysql_query($sql); // echo '
'.$sql.'
'; for($i=0;($result = mysql_fetch_assoc($qry)) != null && $i<$entries;$i++){ $returnArray[$i] = $result; } return $returnArray; } function getCommentCount($pollid){ $temp = mysql_fetch_assoc(mysql_query('Select count(*) as anzahl from poll_votes where comment != \'\' and pollid= '.$pollid)); return $temp[anzahl]; } function getPollResult($pollid){ $returnArray = array(); $sql = 'SELECT text, pv.polloptionid, count(pv.polloptionid) as anzahl FROM poll_votes as pv inner join poll_options as po on pv.polloptionid = po.polloptionid and pv.pollid = po.pollid where pv.pollid = '.$pollid.' group by polloptionid'; $qry = mysql_query($sql); // echo '
'.$sql.'
'; while($result = mysql_fetch_assoc($qry)){ $returnArray[$result[polloptionid]] = $result[anzahl]; } return $returnArray; } function isOpen($pollid){ $sql = 'SELECT count(*) as anzahl from poll where pollid ='.$pollid.' AND (close is null OR close > now())'; $qry = mysql_query($sql); $row = mysql_fetch_assoc($qry); if($row['anzahl'] > 0){ return true; } return false; } ?>