function stimme($pollid, $polloptionid, $userid, $kommentar){
if(mysql_num_rows(mysql_query('SELECT * FROM poll_votes WHERE pollid = '.$pollid.' and userid = '.$userid)) == 0){
// NEU einfuegen!
$sql = 'INSERT INTO poll_votes(pollid, polloptionid, userid, comment) values ('.$pollid.','.$polloptionid.','.$userid.',\''.$kommentar.'\')';
mysql_query($sql);
//echo $sql.'<br>';
} 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);
$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'));
$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';