hiho
hier ein script, dass bei http://www.the-chaosplanet.de.vu unter der gallery zum einsatz kommt
is von mir geproggt und sehr praktisch :wink:
MySQL
CREATE TABLE `poll` (
  `bildid` varchar(10) NOT NULL default '',
  `a` int(11) NOT NULL default '0',
  `b` int(11) NOT NULL default '0',
  `c` int(11) NOT NULL default '0',
  `d` int(11) NOT NULL default '0',
  `e` int(11) NOT NULL default '0',
  `f` int(11) NOT NULL default '0'
) TYPE=MyISAM;
# --------------------------------------------------------
#
# Tabellenstruktur für Tabelle `poll_ip`
#
CREATE TABLE `poll_ip` (
  `ip` varchar(15) NOT NULL default '',
  `time` varchar(11) NOT NULL default '',
  `forpoll` varchar(5) NOT NULL default ''
) TYPE=MyISAM;
    
config.php
<?php
/* Datenbank infos */
$db_host = "localhost";
$db_user = "root";
$db_passwort = "";
$db_tabelle = "test";
$db_connect = mysql_connect($db_host, $db_user, $db_passwort);
mysql_select_db($db_tabelle, $db_connect);
?>
poll.php
<?php
include("config.php");
function form($bild, $show, $show2)
{
	echo "
	<form action=\"\" method=\"get\">
	<input type=\"hidden\" name=\"vote\" value=\"$bild\">
	<select name=\"was\">
	<option value=\"a\"> 1 Punkt </option>
	<option value=\"b\"> 2 Punkte </option>
	<option value=\"c\"> 3 Punkte </option>
	<option value=\"d\"> 4 Punkte </option>
	<option value=\"e\"> 5 Punkte </option>
	<option value=\"f\"> 6 Punkte </option>
	</select>
	<input type=\"submit\" value=\"Vote\">
	</form>
	<a onClick=\"info=window.open('diagramm.php?bild=$bild', 'Diagramm', 'width=410, height=170, menubar=no, location=no, status=no, toolbar=no, scrollbars=no, resizable=no');\" href=\"#\">Tortendiagramm in neuem Fenster anzeigen</a><br \>";
	if($show=='true') 
	{ 
		echo "
		<a href=\"?bild=$bild&show=false\">Tortendiagramm ausblenden</a><br \>
		<img src=\"diagramm.php?bild=$bild\" width=\"400\" height=\160\"><br \>"; 
	}
	else 
	{ 
		echo "
		<a href=\"?bild=$bild&show=true\">Tortendiagramm anzeigen</a><br \>";
	}	
	if($show2=='true') 
	{ 
		echo "
		<a href=\"?bild=$bild&show2=false\">Übersicht ausblenden</a><br \><br \>"; 
		include("poll_uebersicht.php");
	}
	else 
	{ 
		echo "
		<a href=\"?bild=$bild&show2=true\">Übersicht anzeigen</a><br \>";
	}
}
function show($bild)
{
	$query = mysql_query("SELECT * FROM `poll` WHERE bildid = $bild");
	$result = mysql_fetch_object($query);
	if($result)
	{
		$bildid = $bild;
		$a = $result->a;
		$b = $result->b;
		$c = $result->c;
		$d = $result->d;
		$e = $result->e;
		$f = $result->f;
		if($a=='0' && $b=='0' && $c=='0' && $d=='0' && $e=='0' && $f=='0') { $a = "1"; }
		$klicks = $a+$b+$c+$d+$e+$f;
		$vote1 = "$a"*"1";
		$vote2 = "$b"*"2";
		$vote3 = "$c"*"3";
		$vote4 = "$d"*"4";
		$vote5 = "$e"*"5";
		$vote6 = "$f"*"6";
		$vote = "$vote1"+"$vote2"+"$vote3"+"$vote4"+"$vote5"+"$vote6";
		$punkte = "$vote"/"$klicks";
		$punkte = round($punkte, 3);
		
		
		echo "
		Das Bild hat durchschnittlich $punkte Punkte erreicht<br> es haben $klicks leutz gevotet<br>";
		for ($i=0; $i<7; $i++)
		{
			switch($i)
			{
				case 1:
				$percent = "$a"/"$klicks"*"100";
				$percent = round($percent, 3);
				echo "
				1 Punkt : $a [ $percent %]<br \>";
				break;
				
				case 2:
				$percent = "$b"/"$klicks"*"100";
				$percent = round($percent, 3);
				echo "
				2 Punkte : $b [ $percent %]<br \>";
				break;
				
				case 3:
				$percent = "$c"/"$klicks"*"100";
				$percent = round($percent, 3);
				$forpunkte = "$c"*"3";
				echo "
				3 Punkte : $c [ $percent %]<br \>";
				break;
				
				case 4:
				$percent = "$d"/"$klicks"*"100";
				$percent = round($percent, 3);
				echo "
				4 Punkte : $d [ $percent %]<br \>";
				break;
				
				case 5:
				$percent = "$e"/"$klicks"*"100";
				$percent = round($percent, 3);
				echo "
				5 Punkte : $e [ $percent %]<br \>";
				break;
				
				case 6:
				$percent = "$f"/"$klicks"*"100";
				$percent = round($percent, 3);
				echo "
				6 Punkte : $f [ $percent %]<br \>";
				break;
			}
		}
	}
}
function vote($vote, $was)
{
	$sperre = time()-3600;
	$jetzt = time();
	$danke = "
	<div style=\"font-color:green;\">Danke, dass du am Poll teilgenommen hast!<br \><a href=\"index.php?bild=".$vote."\">zurück</a></div>";
	$fehler = "
	<div style=\"font-color:red;\">Du hast schon am Poll teilgenommen!<br \><a href=\"index.php?bild=".$vote."\">zurück</a></div>";
	
	if(getenv("HTTP_X_FORWARDED_FOR")) { $ip = getenv("HTTP_X_FORWARDED_FOR"); }
	else { $ip = getenv("REMOTE_ADDR"); }
	
	mysql_query("DELETE FROM poll_ip WHERE time<$sperre AND forpoll = '$vote'") or die(mysql_error());
	$pruef = mysql_query("SELECT ip FROM poll_ip WHERE ip='$ip' AND forpoll = '$vote'") or die(mysql_error());
	
	if(@!mysql_fetch_array($pruef)) 
	{ 
		mysql_query("INSERT INTO poll_ip (ip, time, forpoll) VALUES ('$ip', '$jetzt', '$vote')") or die(mysql_error());
		$update = mysql_query("UPDATE poll Set $was = $was+1 WHERE bildid = '$vote'") or die(mysql_error());
		if($update) { echo "$danke"; }
	} 
	else { echo "$fehler"; }
}
if(!isset($_GET[bild])) { $bild = "1"; }
else { $bild = $_GET['bild']; }
if(!isset($_GET[show])) { $show = false; }
else { $show = $_GET['show']; }
if(isset($_GET['vote'])) { $vote = $_GET['vote']; }
if(isset($_GET['was'])) { $was = $_GET['was']; }
if(isset($vote) && isset($was)) { vote($vote, $was); }
else { show($bild); form($bild, $show, $show2); }
?>
diagramm.php
<?php
include("config.php");
if(!isset($bild)) { $bild = "1"; }
if(isset($_GET['bild'])) { $bild = $_GET['bild']; }
$query = mysql_query("SELECT * FROM `poll` WHERE bildid = $bild");
$result = mysql_fetch_object($query);
if($result)
{
	// klicks auslesen
	$bildid = $bild;
	$a = $result->a;
	$b = $result->b;
	$c = $result->c;
	$d = $result->d;
	$e = $result->e;
	$f = $result->f;
	if($a == '0' && $b == '0' && $c== '0' && $d == '0' && $e == '0' && $f == '0') { $a="1"; }
	$klicks = $a + $b + $c + $d + $e + $f;
	
	
	// Durschschnitt berechnen
	$punkt1 = "$a"*"1";
	$punkt2 = "$b"*"2";
	$punkt3 = "$c"*"3";
	$punkt4 = "$d"*"4";
	$punkt5 = "$e"*"5";
	$punkt6 = "$f"*"6";
	
	$punkte = "$punkt1"+"$punkt2"+"$punkt3"+"$punkt4"+"$punkt5"+"$punkt6";
	$punkte = "$punkte"/"$klicks";
	$punkte = round($punkte,3);
	// Arrays
	$gesamt = array($a, $b, $c, $d, $e, $f);
	$antworten = array("1 Punkt ", "2 Punkte ", "3 Punkte ", "4 Punkte ", "5 Punkte ", "6 Punkte ");
	
	// Bild erzeugen
	header("Content-type:image/png");
	$pic = imagecreatetruecolor(400, 160);
	$bg = imagecolorallocate($pic, 255, 255, 255);
	imagefilledrectangle($pic, 0, 0, 400, 160, $bg);
	
	
	$colors = array(imagecolorallocate($pic, 255, 51, 51), imagecolorallocate($pic, 51, 255, 51), imagecolorallocate($pic, 51, 51, 255), imagecolorallocate($pic, 204, 204, 51), imagecolorallocate($pic, 51, 51, 51), imagecolorallocate($pic, 204, 204, 204));
	// Kreisdiagramm und Text ausgeben
	$start = 0;    
	$i = 0;  
	foreach ($gesamt as $einzeln) 
	{
		$ende = $start + 360 * intval($einzeln) / $klicks;
		imagefilledarc($pic, 320, 80, 150, 150, $start, $ende, $colors[$i], IMG_ARC_PIE);
		 
		$bla =  "10"+"20"*"$i";
		$percent = "$einzeln"/"$klicks"*"100";
		$percent = round($percent, 3);
		$antwort = "$antworten[$i] [ $percent %] : $einzeln";
		$color = imagecolorallocate($pic, 0, 0, 0);
		imagestring($pic, 10, 0, $bla, $antwort, $colors[$i]);
	
		//Hochzählen
		$start = $ende;
		$i++;   
	}
	
	$color = imagecolorallocate($pic, 0, 0, 0);
	imagestring($pic, 5, 5, 5, "", $color);
	imagepng($pic);
	imagedestroy($pic);
}	
?>
bei fragen 192853407 oder pn ;)
mfg Lucas